|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
Build and execute a DAG of audio processing nodes. More...

Modules | |
| Audio device node factories | |
| Hardware-backed source and sink node factories for the audio graph. | |
| Audio node types and built-in factories | |
| Core types for audio nodes, formats, buffers, and built-in processor node factories. | |
Data Structures | |
| struct | ove_audio_edge |
| Directed connection between two nodes in the audio graph. More... | |
| struct | ove_audio_graph_stats |
| Runtime diagnostic counters for an audio graph. More... | |
| struct | ove_audio_graph |
| Audio processing graph instance. More... | |
Macros | |
| #define | OVE_AUDIO_GRAPH_MAX_NODES 16 |
| Maximum number of nodes in a single audio graph. | |
| #define | OVE_AUDIO_GRAPH_MAX_EDGES 16 |
| Maximum number of edges in a single audio graph. | |
| #define | OVE_AUDIO_GRAPH_STORAGE_BYTES(nodes, frames, channels, sample_bytes) ((size_t)(nodes) * (size_t)(frames) * (size_t)(channels) * (size_t)(sample_bytes)) |
| Conservative upper-bound byte count for graph buffer storage. | |
| #define | OVE_AUDIO_GRAPH_DEFINE(name, nodes, frames, channels, sample_bytes) |
| Declare named static storage for an audio graph and its buffers. | |
Enumerations | |
| enum | ove_audio_graph_state { OVE_AUDIO_GRAPH_IDLE , OVE_AUDIO_GRAPH_READY , OVE_AUDIO_GRAPH_RUNNING } |
| Lifecycle state of an audio graph. More... | |
Functions | |
| int | ove_audio_graph_init (struct ove_audio_graph *g, unsigned int frames_per_period) |
| Initialise an audio graph. | |
| void | ove_audio_graph_deinit (struct ove_audio_graph *g) |
| Release all resources held by an audio graph. | |
| int | ove_audio_graph_add_node (struct ove_audio_graph *g, const struct ove_audio_node_ops *ops, void *ctx, const char *name, enum ove_audio_node_type type) |
| Register a new node in the graph. | |
| int | ove_audio_graph_connect (struct ove_audio_graph *g, unsigned int from, unsigned int to) |
| Connect two nodes with a directed edge. | |
| int | ove_audio_graph_set_buf_storage (struct ove_audio_graph *g, void *storage, size_t size) |
| Provide caller-owned storage for inter-node audio buffers. | |
| int | ove_audio_graph_build (struct ove_audio_graph *g) |
| Validate and compile the graph. | |
| int | ove_audio_graph_start (struct ove_audio_graph *g) |
| Start the audio graph. | |
| int | ove_audio_graph_stop (struct ove_audio_graph *g) |
| Stop the audio graph. | |
| int | ove_audio_graph_process (struct ove_audio_graph *g) |
| Execute one processing cycle (app-driven mode). | |
| int | ove_audio_graph_get_stats (const struct ove_audio_graph *g, struct ove_audio_graph_stats *stats) |
| Retrieve a snapshot of graph runtime statistics. | |
Build and execute a DAG of audio processing nodes.
The audio graph engine models audio processing as a directed acyclic graph (DAG) of typed nodes connected by edges:
The graph is static: configured at init, validated at build time via topological sort and format propagation, then started. Changes require stop, reconfigure, restart.
Execution modes:
Requires CONFIG_OVE_AUDIO.
| #define OVE_AUDIO_GRAPH_STORAGE_BYTES | ( | nodes, | |
| frames, | |||
| channels, | |||
| sample_bytes | |||
| ) | ((size_t)(nodes) * (size_t)(frames) * (size_t)(channels) * (size_t)(sample_bytes)) |
Conservative upper-bound byte count for graph buffer storage.
Computes the worst-case storage required for inter-node audio buffers: every non-sink node produces one buffer of frames × channels × sample_bytes. Used by ove_audio_graph_create and OVE_AUDIO_GRAPH_DEFINE to size a zero-heap static backing array.
| #define OVE_AUDIO_GRAPH_DEFINE | ( | name, | |
| nodes, | |||
| frames, | |||
| channels, | |||
| sample_bytes | |||
| ) |
Declare named static storage for an audio graph and its buffers.
Mirrors OVE_THREAD_DEFINE / OVE_QUEUE_DEFINE: emits two file-scope static objects: the ove_audio_graph instance named name, and a byte array named name##_buf sized via OVE_AUDIO_GRAPH_STORAGE_BYTES. Pair with ove_audio_graph_init and ove_audio_graph_set_buf_storage when the application wants explicit control:
Applications that do not need this level of control should prefer ove_audio_graph_create, which allocates and attaches storage in one step.
| int ove_audio_graph_init | ( | struct ove_audio_graph * | g, |
| unsigned int | frames_per_period | ||
| ) |
Initialise an audio graph.
Sets up internal state and records the processing period size. Must be called before any other graph function.
| [in] | g | Graph instance to initialise. |
| [in] | frames_per_period | Number of audio frames processed per cycle. |
CONFIG_OVE_AUDIO. | void ove_audio_graph_deinit | ( | struct ove_audio_graph * | g | ) |
Release all resources held by an audio graph.
Stops the graph (if running), tears down each node, and frees the heap-allocated inter-node buffer block. Caller-supplied buffer storage registered via ove_audio_graph_set_buf_storage is left intact.
| [in] | g | Initialised graph instance. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_add_node | ( | struct ove_audio_graph * | g, |
| const struct ove_audio_node_ops * | ops, | ||
| void * | ctx, | ||
| const char * | name, | ||
| enum ove_audio_node_type | type | ||
| ) |
Register a new node in the graph.
Appends a node entry to the graph's node table. Nodes may only be added while the graph is in the OVE_AUDIO_GRAPH_IDLE state.
| [in] | g | Graph instance. |
| [in] | ops | Vtable providing the node implementation. |
| [in] | ctx | Opaque context pointer forwarded to every vtable call. |
| [in] | name | Human-readable node name for diagnostics. |
| [in] | type | Role of the node: source, processor, or sink. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_connect | ( | struct ove_audio_graph * | g, |
| unsigned int | from, | ||
| unsigned int | to | ||
| ) |
Connect two nodes with a directed edge.
Adds an edge from the node at index from to the node at index to. Both nodes must already be registered. Edges may only be added while the graph is in the OVE_AUDIO_GRAPH_IDLE state.
| [in] | g | Graph instance. |
| [in] | from | Index of the upstream (producer) node. |
| [in] | to | Index of the downstream (consumer) node. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_set_buf_storage | ( | struct ove_audio_graph * | g, |
| void * | storage, | ||
| size_t | size | ||
| ) |
Provide caller-owned storage for inter-node audio buffers.
Must be called after ove_audio_graph_init and before ove_audio_graph_build. When set, ove_audio_graph_build uses this buffer instead of calling calloc, and ove_audio_graph_deinit will not free it. This is the only way to build a graph under CONFIG_OVE_ZERO_HEAP. Use OVE_AUDIO_GRAPH_STORAGE_BYTES to size the backing array.
| [in] | g | Graph instance in the OVE_AUDIO_GRAPH_IDLE state. |
| [in] | storage | Pointer to caller-owned memory (≥ size bytes). |
| [in] | size | Size of storage in bytes; must be large enough to cover every non-sink node's output buffer. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_build | ( | struct ove_audio_graph * | g | ) |
Validate and compile the graph.
Performs a topological sort, propagates audio formats from sources to sinks by calling each node's configure callback, allocates the inter-node audio buffers, and transitions the graph to OVE_AUDIO_GRAPH_READY.
| [in] | g | Graph instance in the OVE_AUDIO_GRAPH_IDLE state. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_start | ( | struct ove_audio_graph * | g | ) |
Start the audio graph.
Calls each node's start callback in topological order and transitions the graph to OVE_AUDIO_GRAPH_RUNNING. The graph must be in the OVE_AUDIO_GRAPH_READY state.
| [in] | g | Built graph instance. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_stop | ( | struct ove_audio_graph * | g | ) |
Stop the audio graph.
Calls each node's stop callback in reverse topological order and transitions the graph back to OVE_AUDIO_GRAPH_READY.
| [in] | g | Running graph instance. |
CONFIG_OVE_AUDIO. | int ove_audio_graph_process | ( | struct ove_audio_graph * | g | ) |
Execute one processing cycle (app-driven mode).
Calls each node's process callback in topological order, passing inter-node buffers along the edges. Intended for test or offline use; in sink-driven mode the hardware callback drives processing instead.
| [in] | g | Graph instance in OVE_AUDIO_GRAPH_READY or OVE_AUDIO_GRAPH_RUNNING state. |
OVE_ERR_NOT_SUPPORTED if the graph has not been built, or another negative error code if any node reports an error.CONFIG_OVE_AUDIO. | int ove_audio_graph_get_stats | ( | const struct ove_audio_graph * | g, |
| struct ove_audio_graph_stats * | stats | ||
| ) |
Retrieve a snapshot of graph runtime statistics.
Copies the current diagnostic counters from the graph into the caller-supplied stats structure. Valid in any state once ove_audio_graph_init has succeeded.
| [in] | g | Graph instance. |
| [out] | stats | Pointer to a caller-allocated structure that will receive the statistics snapshot. |
OVE_ERR_INVALID_PARAM if g or stats is NULL.CONFIG_OVE_AUDIO.