oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
audio.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-3.0-or-later */
2
27#ifndef OVE_AUDIO_H
28#define OVE_AUDIO_H
29
30#include "ove/audio_node.h"
31#include "ove/storage.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifdef CONFIG_OVE_AUDIO
38
39/* ── Graph limits ───────────────────────────────────────────────── */
40
42#define OVE_AUDIO_GRAPH_MAX_NODES 16
44#define OVE_AUDIO_GRAPH_MAX_EDGES 16
45
46/* ── Edge ───────────────────────────────────────────────────────── */
47
54 unsigned int from;
55 unsigned int to;
56};
57
58/* ── Diagnostics ────────────────────────────────────────────────── */
59
67 unsigned int cycles;
68 unsigned int underruns;
69 unsigned int overruns;
70 unsigned int node_errors;
71 unsigned int max_process_us;
72 unsigned int
74};
75
76/* ── Graph ──────────────────────────────────────────────────────── */
77
88
119
120/* ── Graph API ──────────────────────────────────────────────────── */
121
135int ove_audio_graph_init(struct ove_audio_graph *g, unsigned int frames_per_period);
136
150
168 void *ctx, const char *name, enum ove_audio_node_type type);
169
185int ove_audio_graph_connect(struct ove_audio_graph *g, unsigned int from, unsigned int to);
186
206int ove_audio_graph_set_buf_storage(struct ove_audio_graph *g, void *storage, size_t size);
207
216#define OVE_AUDIO_GRAPH_STORAGE_BYTES(nodes, frames, channels, sample_bytes) \
217 ((size_t)(nodes) * (size_t)(frames) * (size_t)(channels) * (size_t)(sample_bytes))
218
219/* ── _create / _destroy — heap-mode only (gated by OVE_HEAP_AUDIO) ───── */
220#ifdef OVE_HEAP_AUDIO
221
236int ove_audio_graph_create_(struct ove_audio_graph *g, unsigned int frames);
237
244int ove_audio_graph_destroy(struct ove_audio_graph *g);
245
266#define ove_audio_graph_create(pg, frames, nodes, channels, sample_bytes) \
267 ((void)(nodes), (void)(channels), (void)(sample_bytes), \
268 ove_audio_graph_create_((pg), (frames)))
269
270#endif /* OVE_HEAP_AUDIO */
271
292#define OVE_AUDIO_GRAPH_DEFINE(name, nodes, frames, channels, sample_bytes) \
293 static uint8_t name##_buf[OVE_AUDIO_GRAPH_STORAGE_BYTES( \
294 (nodes), (frames), (channels), (sample_bytes))] __attribute__((aligned(4))); \
295 static struct ove_audio_graph name
296
313
328
342
360
377
378#else /* !CONFIG_OVE_AUDIO */
379
380struct ove_audio_graph {
381 int _unused;
382};
383
384static inline int ove_audio_graph_init(struct ove_audio_graph *g, unsigned int f)
385{
386 (void)g;
387 (void)f;
388 return -5; /* OVE_ERR_NOT_SUPPORTED */
389}
390static inline void ove_audio_graph_deinit(struct ove_audio_graph *g)
391{
392 (void)g;
393}
394
395#endif /* CONFIG_OVE_AUDIO */
396
397#ifdef __cplusplus
398}
399#endif
400
/* end of ove_audio group */
402
403#endif /* OVE_AUDIO_H */
ove_audio_node_type
Role of a node within the audio graph.
Definition audio_node.h:183
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_process(struct ove_audio_graph *g)
Execute one processing cycle (app-driven mode).
int ove_audio_graph_start(struct ove_audio_graph *g)
Start the audio graph.
int ove_audio_graph_init(struct ove_audio_graph *g, unsigned int frames_per_period)
Initialise an audio graph.
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.
ove_audio_graph_state
Lifecycle state of an audio graph.
Definition audio.h:83
int ove_audio_graph_stop(struct ove_audio_graph *g)
Stop the audio graph.
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.
#define OVE_AUDIO_GRAPH_MAX_EDGES
Maximum number of edges in a single audio graph.
Definition audio.h:44
int ove_audio_graph_connect(struct ove_audio_graph *g, unsigned int from, unsigned int to)
Connect two nodes with a directed edge.
void ove_audio_graph_deinit(struct ove_audio_graph *g)
Release all resources held by an audio graph.
#define OVE_AUDIO_GRAPH_MAX_NODES
Maximum number of nodes in a single audio graph.
Definition audio.h:42
int ove_audio_graph_build(struct ove_audio_graph *g)
Validate and compile the graph.
@ OVE_AUDIO_GRAPH_RUNNING
Graph is actively processing audio.
Definition audio.h:86
@ OVE_AUDIO_GRAPH_IDLE
Initial state; nodes may be added and connected.
Definition audio.h:84
@ OVE_AUDIO_GRAPH_READY
Build succeeded; graph may be started.
Definition audio.h:85
Audio buffer passed between nodes during graph processing.
Definition audio_node.h:102
Directed connection between two nodes in the audio graph.
Definition audio.h:53
unsigned int from
Index of the upstream (producer) node.
Definition audio.h:54
unsigned int to
Index of the downstream (consumer) node.
Definition audio.h:55
Runtime diagnostic counters for an audio graph.
Definition audio.h:66
unsigned int max_process_us
Worst-case cycle wall-clock time in microseconds.
Definition audio.h:71
unsigned int node_errors
Cumulative node process() failures.
Definition audio.h:70
unsigned int cycles
Number of completed processing cycles.
Definition audio.h:67
unsigned int avg_process_us
Rolling average cycle wall-clock time in microseconds.
Definition audio.h:73
unsigned int overruns
Source overflow events (source dropped frames).
Definition audio.h:69
unsigned int underruns
Sink starvation events (sink received no data).
Definition audio.h:68
Audio processing graph instance.
Definition audio.h:96
struct ove_audio_graph_stats stats
Accumulated runtime diagnostics.
Definition audio.h:117
size_t buf_storage_size
Size of caller-provided storage (0 = heap-allocated).
Definition audio.h:112
struct ove_audio_edge edges[OVE_AUDIO_GRAPH_MAX_EDGES]
Registered directed edges.
Definition audio.h:101
unsigned int frames_per_period
Frame count processed per graph cycle.
Definition audio.h:114
struct ove_audio_buf buffers[OVE_AUDIO_GRAPH_MAX_NODES]
Per-node intermediate audio buffers.
Definition audio.h:109
void * buf_storage
Heap block backing all buffer data arrays.
Definition audio.h:111
unsigned int node_count
Number of valid entries in nodes[].
Definition audio.h:99
unsigned int exec_count
Number of valid entries in exec_order[].
Definition audio.h:107
struct ove_audio_node nodes[OVE_AUDIO_GRAPH_MAX_NODES]
Registered node descriptors.
Definition audio.h:97
unsigned int exec_order[OVE_AUDIO_GRAPH_MAX_NODES]
Node indices in topological execution order.
Definition audio.h:106
enum ove_audio_graph_state state
Current lifecycle state.
Definition audio.h:115
unsigned int edge_count
Number of valid entries in edges[].
Definition audio.h:103
Virtual function table (vtable) for an audio processing node.
Definition audio_node.h:118
Descriptor for a single node in the audio graph.
Definition audio_node.h:195