Some code semantics refactoring.
This commit is contained in:
parent
de403b37d7
commit
0f04e056b2
42 changed files with 3374 additions and 1357 deletions
|
|
@ -6,11 +6,14 @@
|
|||
xtc_result xtc_graph_create(size_t max_nodes, xtc_graph **out_graph)
|
||||
{
|
||||
xtc_graph *graph;
|
||||
if (out_graph == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (out_graph == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
*out_graph = NULL;
|
||||
if (max_nodes == 0U || max_nodes > XTC_MAX_NODES) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (max_nodes == 0U || max_nodes > XTC_MAX_NODES)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
graph = calloc(1U, sizeof(*graph));
|
||||
if (graph == NULL) return XTC_ERR_OUT_OF_MEMORY;
|
||||
if (graph == NULL)
|
||||
return XTC_ERR_OUT_OF_MEMORY;
|
||||
graph->nodes = calloc(max_nodes, sizeof(*graph->nodes));
|
||||
graph->edges = calloc(max_nodes * max_nodes, sizeof(*graph->edges));
|
||||
if (graph->nodes == NULL || graph->edges == NULL) {
|
||||
|
|
@ -34,49 +37,71 @@ void xtc_graph_destroy(xtc_graph *graph)
|
|||
static size_t node_index(const xtc_graph *graph, size_t id)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0U; i < graph->node_count; ++i) if (graph->nodes[i].id == id) return i;
|
||||
for (i = 0U; i < graph->node_count; ++i)
|
||||
if (graph->nodes[i].id == id)
|
||||
return i;
|
||||
return SIZE_MAX;
|
||||
}
|
||||
|
||||
static xtc_result add_node(xtc_graph *graph, xtc_node_type type, float value,
|
||||
size_t *out_node_id)
|
||||
static xtc_result add_node(xtc_graph *graph, xtc_node_type type, float value, size_t *out_node_id)
|
||||
{
|
||||
if (graph == NULL || out_node_id == NULL || !isfinite(value))
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (graph->node_count == graph->max_nodes || graph->next_id == SIZE_MAX) return XTC_ERR_CAPACITY;
|
||||
if (graph->node_count == graph->max_nodes || graph->next_id == SIZE_MAX)
|
||||
return XTC_ERR_CAPACITY;
|
||||
graph->nodes[graph->node_count].type = type;
|
||||
graph->nodes[graph->node_count].value = value;
|
||||
graph->nodes[graph->node_count++].id = graph->next_id;
|
||||
*out_node_id = graph->next_id++;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_add_gain(xtc_graph *graph, float gain, size_t *out_node_id)
|
||||
{ return add_node(graph, XTC_NODE_GAIN, gain, out_node_id); }
|
||||
{
|
||||
return add_node(graph, XTC_NODE_GAIN, gain, out_node_id);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_add_oscillator(xtc_graph *graph, float frequency, size_t *out_node_id)
|
||||
{
|
||||
if (frequency < 0.0f) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (frequency < 0.0f)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
return add_node(graph, XTC_NODE_OSCILLATOR, frequency, out_node_id);
|
||||
}
|
||||
xtc_result xtc_graph_add_meter(xtc_graph *graph, size_t *out_node_id)
|
||||
{ return add_node(graph, XTC_NODE_METER, 0.0f, out_node_id); }
|
||||
xtc_result xtc_graph_add_instrument(xtc_graph *graph, size_t *out_node_id)
|
||||
{ return add_node(graph, XTC_NODE_INSTRUMENT, 0.0f, out_node_id); }
|
||||
xtc_result xtc_graph_add_audio(xtc_graph *graph, size_t *out_node_id)
|
||||
{ return add_node(graph, XTC_NODE_AUDIO, 0.0f, out_node_id); }
|
||||
xtc_result xtc_graph_add_output(xtc_graph *graph, size_t *out_node_id)
|
||||
{ return add_node(graph, XTC_NODE_OUTPUT, 0.0f, out_node_id); }
|
||||
|
||||
xtc_result xtc_graph_get_port(const xtc_graph *graph, size_t node_id,
|
||||
size_t port_id, xtc_port_info *out_port)
|
||||
xtc_result xtc_graph_add_meter(xtc_graph *graph, size_t *out_node_id)
|
||||
{
|
||||
return add_node(graph, XTC_NODE_METER, 0.0f, out_node_id);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_add_instrument(xtc_graph *graph, size_t *out_node_id)
|
||||
{
|
||||
return add_node(graph, XTC_NODE_INSTRUMENT, 0.0f, out_node_id);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_add_audio(xtc_graph *graph, size_t *out_node_id)
|
||||
{
|
||||
return add_node(graph, XTC_NODE_AUDIO, 0.0f, out_node_id);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_add_output(xtc_graph *graph, size_t *out_node_id)
|
||||
{
|
||||
return add_node(graph, XTC_NODE_OUTPUT, 0.0f, out_node_id);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_get_port(const xtc_graph *graph, size_t node_id, size_t port_id, xtc_port_info *out_port)
|
||||
{
|
||||
xtc_node_type type;
|
||||
if (graph == NULL || out_port == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (graph == NULL || out_port == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
node_id = node_index(graph, node_id);
|
||||
if (node_id == SIZE_MAX) return XTC_ERR_NOT_FOUND;
|
||||
if (node_id == SIZE_MAX)
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
type = graph->nodes[node_id].type;
|
||||
if (port_id > 1U || (port_id == 0U && (type == XTC_NODE_OSCILLATOR || type == XTC_NODE_AUDIO || type == XTC_NODE_INSTRUMENT ||
|
||||
(type == XTC_NODE_NATIVE && graph->nodes[node_id].native.kind != XTC_NATIVE_EFFECT))) ||
|
||||
(port_id == 1U && type == XTC_NODE_OUTPUT)) return XTC_ERR_NOT_FOUND;
|
||||
if (port_id > 1U ||
|
||||
(port_id == 0U && (type == XTC_NODE_OSCILLATOR || type == XTC_NODE_AUDIO || type == XTC_NODE_INSTRUMENT ||
|
||||
(type == XTC_NODE_NATIVE && graph->nodes[node_id].native.kind != XTC_NATIVE_EFFECT))) ||
|
||||
(port_id == 1U && type == XTC_NODE_OUTPUT))
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
out_port->direction = port_id == 0U ? XTC_PORT_INPUT : XTC_PORT_OUTPUT;
|
||||
out_port->signal_type = XTC_SIGNAL_AUDIO;
|
||||
out_port->channel_count = 1U;
|
||||
|
|
@ -87,17 +112,20 @@ xtc_result xtc_graph_order(const xtc_graph *graph, size_t *order)
|
|||
{
|
||||
size_t indegree[XTC_MAX_NODES] = {0U};
|
||||
size_t head = 0U, tail = 0U, i;
|
||||
if (graph == NULL || order == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (graph == NULL || order == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
for (i = 0U; i < graph->edge_count; ++i)
|
||||
++indegree[graph->edges[i].destination];
|
||||
for (i = 0U; i < graph->node_count; ++i)
|
||||
if (indegree[i] == 0U) order[tail++] = i;
|
||||
if (indegree[i] == 0U)
|
||||
order[tail++] = i;
|
||||
while (head < tail) {
|
||||
size_t node = order[head++];
|
||||
for (i = 0U; i < graph->edge_count; ++i) {
|
||||
if (graph->edges[i].source == node) {
|
||||
size_t dest = graph->edges[i].destination;
|
||||
if (--indegree[dest] == 0U) order[tail++] = dest;
|
||||
if (--indegree[dest] == 0U)
|
||||
order[tail++] = dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,16 +138,17 @@ xtc_result xtc_graph_validate(const xtc_graph *graph)
|
|||
return xtc_graph_order(graph, order);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_connect_ports(xtc_graph *graph, size_t source_node,
|
||||
size_t source_port, size_t destination_node,
|
||||
size_t destination_port)
|
||||
xtc_result xtc_graph_connect_ports(xtc_graph *graph, size_t source_node, size_t source_port, size_t destination_node,
|
||||
size_t destination_port)
|
||||
{
|
||||
xtc_port_info source, dest;
|
||||
size_t i;
|
||||
xtc_result result = xtc_graph_get_port(graph, source_node, source_port, &source);
|
||||
if (result != XTC_OK) return result;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
result = xtc_graph_get_port(graph, destination_node, destination_port, &dest);
|
||||
if (result != XTC_OK) return result;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
if (source.direction != XTC_PORT_OUTPUT || dest.direction != XTC_PORT_INPUT ||
|
||||
source.signal_type != dest.signal_type || source.channel_count != dest.channel_count)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
|
|
@ -128,97 +157,123 @@ xtc_result xtc_graph_connect_ports(xtc_graph *graph, size_t source_node,
|
|||
for (i = 0U; i < graph->edge_count; ++i)
|
||||
if (graph->edges[i].source == source_node && graph->edges[i].destination == destination_node)
|
||||
return XTC_ERR_INVALID_STATE;
|
||||
if (graph->edge_count == graph->max_nodes * graph->max_nodes) return XTC_ERR_CAPACITY;
|
||||
if (graph->edge_count == graph->max_nodes * graph->max_nodes)
|
||||
return XTC_ERR_CAPACITY;
|
||||
graph->edges[graph->edge_count].source = source_node;
|
||||
graph->edges[graph->edge_count++].destination = destination_node;
|
||||
result = xtc_graph_validate(graph);
|
||||
if (result != XTC_OK) --graph->edge_count;
|
||||
if (result != XTC_OK)
|
||||
--graph->edge_count;
|
||||
return result;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_connect(xtc_graph *graph, size_t source_node, size_t destination_node)
|
||||
{ return xtc_graph_connect_ports(graph, source_node, 1U, destination_node, 0U); }
|
||||
{
|
||||
return xtc_graph_connect_ports(graph, source_node, 1U, destination_node, 0U);
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_get_counts(const xtc_graph *graph, size_t *out_nodes, size_t *out_connections)
|
||||
{
|
||||
if (graph == NULL || out_nodes == NULL || out_connections == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (graph == NULL || out_nodes == NULL || out_connections == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
*out_nodes = graph->node_count;
|
||||
*out_connections = graph->edge_count;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_get_node(const xtc_graph *graph, size_t index, xtc_node_info *out_node)
|
||||
{
|
||||
if (graph == NULL || out_node == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (index >= graph->node_count) return XTC_ERR_NOT_FOUND;
|
||||
if (graph == NULL || out_node == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (index >= graph->node_count)
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
out_node->id = graph->nodes[index].id;
|
||||
out_node->type = graph->nodes[index].type;
|
||||
out_node->value = graph->nodes[index].value;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_get_connection(const xtc_graph *graph, size_t index, xtc_connection_info *out_connection)
|
||||
{
|
||||
if (graph == NULL || out_connection == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (index >= graph->edge_count) return XTC_ERR_NOT_FOUND;
|
||||
if (graph == NULL || out_connection == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (index >= graph->edge_count)
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
out_connection->source_node = graph->nodes[graph->edges[index].source].id;
|
||||
out_connection->destination_node = graph->nodes[graph->edges[index].destination].id;
|
||||
out_connection->source_port = 1U;
|
||||
out_connection->destination_port = 0U;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_require_output_nodes(xtc_graph *graph, int required)
|
||||
{
|
||||
if (graph == NULL || (required != 0 && required != 1)) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (graph == NULL || (required != 0 && required != 1))
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
graph->require_output_nodes = required;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
static xtc_result remove_node(xtc_graph *graph, size_t id)
|
||||
{
|
||||
size_t index = node_index(graph, id), i, count = 0U;
|
||||
if (index == SIZE_MAX) return XTC_ERR_NOT_FOUND;
|
||||
if (index == SIZE_MAX)
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
for (i = 0U; i < graph->edge_count; ++i) {
|
||||
xtc_edge edge = graph->edges[i];
|
||||
if (edge.source == index || edge.destination == index) continue;
|
||||
if (edge.source > index) --edge.source;
|
||||
if (edge.destination > index) --edge.destination;
|
||||
if (edge.source == index || edge.destination == index)
|
||||
continue;
|
||||
if (edge.source > index)
|
||||
--edge.source;
|
||||
if (edge.destination > index)
|
||||
--edge.destination;
|
||||
graph->edges[count++] = edge;
|
||||
}
|
||||
graph->edge_count = count;
|
||||
memmove(graph->nodes + index, graph->nodes + index + 1U,
|
||||
(graph->node_count - index - 1U) * sizeof(*graph->nodes));
|
||||
memmove(graph->nodes + index, graph->nodes + index + 1U, (graph->node_count - index - 1U) * sizeof(*graph->nodes));
|
||||
--graph->node_count;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
||||
static xtc_result disconnect_ports(xtc_graph *graph, const xtc_connection_info *connection)
|
||||
{
|
||||
size_t i;
|
||||
xtc_port_info port;
|
||||
xtc_result result = xtc_graph_get_port(graph, connection->source_node, connection->source_port, &port);
|
||||
if (result != XTC_OK) return result;
|
||||
if (port.direction != XTC_PORT_OUTPUT) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
if (port.direction != XTC_PORT_OUTPUT)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
result = xtc_graph_get_port(graph, connection->destination_node, connection->destination_port, &port);
|
||||
if (result != XTC_OK) return result;
|
||||
if (port.direction != XTC_PORT_INPUT) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
if (port.direction != XTC_PORT_INPUT)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
for (i = 0U; i < graph->edge_count; ++i) {
|
||||
if (graph->edges[i].source == node_index(graph, connection->source_node) &&
|
||||
graph->edges[i].destination == node_index(graph, connection->destination_node)) {
|
||||
memmove(graph->edges + i, graph->edges + i + 1U,
|
||||
(graph->edge_count - i - 1U) * sizeof(*graph->edges));
|
||||
memmove(graph->edges + i, graph->edges + i + 1U, (graph->edge_count - i - 1U) * sizeof(*graph->edges));
|
||||
--graph->edge_count;
|
||||
return XTC_OK;
|
||||
}
|
||||
}
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
}
|
||||
xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *edit,
|
||||
xtc_graph **out_graph, size_t *out_added_id)
|
||||
|
||||
xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *edit, xtc_graph **out_graph,
|
||||
size_t *out_added_id)
|
||||
{
|
||||
xtc_graph *graph;
|
||||
xtc_result result;
|
||||
size_t added_id = 0U;
|
||||
if (out_graph == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (out_graph == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
*out_graph = NULL;
|
||||
if (source == NULL || edit == NULL) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (source == NULL || edit == NULL)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
result = xtc_graph_create(source->max_nodes, &graph);
|
||||
if (result != XTC_OK) return result;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
graph->node_count = source->node_count;
|
||||
graph->edge_count = source->edge_count;
|
||||
graph->next_id = source->next_id;
|
||||
|
|
@ -228,26 +283,50 @@ xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *e
|
|||
switch (edit->kind) {
|
||||
case XTC_EDIT_ADD_NODE:
|
||||
switch (edit->data.add.type) {
|
||||
case XTC_NODE_GAIN: result = xtc_graph_add_gain(graph, edit->data.add.value, &added_id); break;
|
||||
case XTC_NODE_OSCILLATOR: result = xtc_graph_add_oscillator(graph, edit->data.add.value, &added_id); break;
|
||||
case XTC_NODE_METER: result = xtc_graph_add_meter(graph, &added_id); break;
|
||||
case XTC_NODE_INSTRUMENT: result = xtc_graph_add_instrument(graph, &added_id); break;
|
||||
case XTC_NODE_AUDIO: result = xtc_graph_add_audio(graph, &added_id); break;
|
||||
case XTC_NODE_OUTPUT: result = xtc_graph_add_output(graph, &added_id); break;
|
||||
default: result = XTC_ERR_INVALID_ARGUMENT; break;
|
||||
case XTC_NODE_GAIN:
|
||||
result = xtc_graph_add_gain(graph, edit->data.add.value, &added_id);
|
||||
break;
|
||||
case XTC_NODE_OSCILLATOR:
|
||||
result = xtc_graph_add_oscillator(graph, edit->data.add.value, &added_id);
|
||||
break;
|
||||
case XTC_NODE_METER:
|
||||
result = xtc_graph_add_meter(graph, &added_id);
|
||||
break;
|
||||
case XTC_NODE_INSTRUMENT:
|
||||
result = xtc_graph_add_instrument(graph, &added_id);
|
||||
break;
|
||||
case XTC_NODE_AUDIO:
|
||||
result = xtc_graph_add_audio(graph, &added_id);
|
||||
break;
|
||||
case XTC_NODE_OUTPUT:
|
||||
result = xtc_graph_add_output(graph, &added_id);
|
||||
break;
|
||||
default:
|
||||
result = XTC_ERR_INVALID_ARGUMENT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XTC_EDIT_REMOVE_NODE: result = remove_node(graph, edit->data.node_id); break;
|
||||
case XTC_EDIT_REMOVE_NODE:
|
||||
result = remove_node(graph, edit->data.node_id);
|
||||
break;
|
||||
case XTC_EDIT_CONNECT:
|
||||
result = xtc_graph_connect_ports(graph, edit->data.connection.source_node,
|
||||
edit->data.connection.source_port, edit->data.connection.destination_node,
|
||||
edit->data.connection.destination_port);
|
||||
result =
|
||||
xtc_graph_connect_ports(graph, edit->data.connection.source_node, edit->data.connection.source_port,
|
||||
edit->data.connection.destination_node, edit->data.connection.destination_port);
|
||||
break;
|
||||
case XTC_EDIT_DISCONNECT:
|
||||
result = disconnect_ports(graph, &edit->data.connection);
|
||||
break;
|
||||
default:
|
||||
result = XTC_ERR_INVALID_ARGUMENT;
|
||||
break;
|
||||
case XTC_EDIT_DISCONNECT: result = disconnect_ports(graph, &edit->data.connection); break;
|
||||
default: result = XTC_ERR_INVALID_ARGUMENT; break;
|
||||
}
|
||||
if (result != XTC_OK) { xtc_graph_destroy(graph); return result; }
|
||||
if (out_added_id != NULL && edit->kind == XTC_EDIT_ADD_NODE) *out_added_id = added_id;
|
||||
if (result != XTC_OK) {
|
||||
xtc_graph_destroy(graph);
|
||||
return result;
|
||||
}
|
||||
if (out_added_id != NULL && edit->kind == XTC_EDIT_ADD_NODE)
|
||||
*out_added_id = added_id;
|
||||
*out_graph = graph;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
|
@ -255,18 +334,26 @@ xtc_result xtc_graph_apply_edit(const xtc_graph *source, const xtc_graph_edit *e
|
|||
xtc_result xtc_graph_add_native(xtc_graph *graph, const xtc_native_descriptor *descriptor, float value, size_t *out)
|
||||
{
|
||||
xtc_result result = xtc_native_validate(descriptor);
|
||||
if (result != XTC_OK) return result;
|
||||
if (descriptor->kind == XTC_NATIVE_INSTRUMENT) return XTC_ERR_UNSUPPORTED;
|
||||
if (result != XTC_OK)
|
||||
return result;
|
||||
if (descriptor->kind == XTC_NATIVE_INSTRUMENT)
|
||||
return XTC_ERR_UNSUPPORTED;
|
||||
result = add_node(graph, XTC_NODE_NATIVE, value, out);
|
||||
if (result == XTC_OK) graph->nodes[graph->node_count - 1].native = *descriptor;
|
||||
if (result == XTC_OK)
|
||||
graph->nodes[graph->node_count - 1].native = *descriptor;
|
||||
return result;
|
||||
}
|
||||
|
||||
xtc_result xtc_graph_get_native(const xtc_graph *graph, size_t id, xtc_native_descriptor *out)
|
||||
{
|
||||
size_t i;
|
||||
if (!graph || !out) return XTC_ERR_INVALID_ARGUMENT;
|
||||
if (!graph || !out)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
i = node_index(graph, id);
|
||||
if (i == SIZE_MAX) return XTC_ERR_NOT_FOUND;
|
||||
if (graph->nodes[i].type != XTC_NODE_NATIVE) return XTC_ERR_INVALID_ARGUMENT;
|
||||
*out = graph->nodes[i].native; return XTC_OK;
|
||||
if (i == SIZE_MAX)
|
||||
return XTC_ERR_NOT_FOUND;
|
||||
if (graph->nodes[i].type != XTC_NODE_NATIVE)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
*out = graph->nodes[i].native;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,30 @@
|
|||
#ifndef XTC_GRAPH_INTERNAL_H
|
||||
#define XTC_GRAPH_INTERNAL_H
|
||||
|
||||
#include "xtc/xtc_engine.h"
|
||||
#include "xtc/xtc_native.h"
|
||||
|
||||
#define XTC_MAX_NODES 256U
|
||||
#define XTC_MAX_FRAMES 65536U
|
||||
typedef struct { xtc_node_type type; float value; size_t id; xtc_native_descriptor native; } xtc_node;
|
||||
typedef struct { size_t source; size_t destination; } xtc_edge;
|
||||
|
||||
typedef struct {
|
||||
xtc_node_type type;
|
||||
float value;
|
||||
size_t id;
|
||||
xtc_native_descriptor native;
|
||||
} xtc_node;
|
||||
|
||||
typedef struct {
|
||||
size_t source;
|
||||
size_t destination;
|
||||
} xtc_edge;
|
||||
|
||||
struct xtc_graph {
|
||||
size_t max_nodes, node_count, edge_count, next_id;
|
||||
int require_output_nodes;
|
||||
xtc_node *nodes;
|
||||
xtc_edge *edges;
|
||||
};
|
||||
|
||||
xtc_result xtc_graph_order(const xtc_graph *graph, size_t *order);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue