oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Modules | Data Structures | Macros | Enumerations | Functions
Audio graph engine

Build and execute a DAG of audio processing nodes. More...

Collaboration diagram for Audio graph engine:

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.
 

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_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.
 

Detailed Description

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.

Enumeration Type Documentation

◆ ove_audio_graph_state

Lifecycle state of an audio graph.

See also
ove_audio_graph_build, ove_audio_graph_start, ove_audio_graph_stop
Enumerator
OVE_AUDIO_GRAPH_IDLE 

Initial state; nodes may be added and connected.

OVE_AUDIO_GRAPH_READY 

Build succeeded; graph may be started.

OVE_AUDIO_GRAPH_RUNNING 

Graph is actively processing audio.

Function Documentation

◆ ove_audio_graph_init()

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.

Parameters
[in]gGraph instance to initialise.
[in]frames_per_periodNumber of audio frames processed per cycle.
Returns
0 on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_deinit

◆ ove_audio_graph_deinit()

void ove_audio_graph_deinit ( struct ove_audio_graph g)

Release all resources held by an audio graph.

Frees the heap buffer storage and resets internal state. The graph must be stopped before calling this function.

Parameters
[in]gInitialised graph instance.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_init

◆ ove_audio_graph_add_node()

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.

Parameters
[in]gGraph instance.
[in]opsVtable providing the node implementation.
[in]ctxOpaque context pointer forwarded to every vtable call.
[in]nameHuman-readable node name for diagnostics.
[in]typeRole of the node: source, processor, or sink.
Returns
Non-negative node index on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_connect, ove_audio_graph_build

◆ ove_audio_graph_connect()

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.

Parameters
[in]gGraph instance.
[in]fromIndex of the upstream (producer) node.
[in]toIndex of the downstream (consumer) node.
Returns
0 on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_add_node, ove_audio_graph_build

◆ ove_audio_graph_build()

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.

Parameters
[in]gGraph instance in the OVE_AUDIO_GRAPH_IDLE state.
Returns
0 on success, negative error code on failure (e.g. cycle detected, format mismatch, or buffer allocation failure).
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_start

◆ ove_audio_graph_start()

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.

Parameters
[in]gBuilt graph instance.
Returns
0 on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_build, ove_audio_graph_stop

◆ ove_audio_graph_stop()

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.

Parameters
[in]gRunning graph instance.
Returns
0 on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_start

◆ ove_audio_graph_process()

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.

Parameters
[in]gRunning graph instance.
Returns
0 on success, negative error code if any node reports an error.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_start

◆ ove_audio_graph_get_stats()

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.

Parameters
[in]gGraph instance (running or ready).
[out]statsPointer to a caller-allocated structure that will receive the statistics snapshot.
Returns
0 on success, negative error code on failure.
Note
Requires CONFIG_OVE_AUDIO.
See also
ove_audio_graph_stats