17#include <ove/audio_device.h>
20#ifdef CONFIG_OVE_AUDIO
32 Graph() : initialized_(
false) {}
36 ove_audio_graph_deinit(&g_);
40 [[nodiscard]]
int init(
unsigned int frames_per_period) {
41 int ret = ove_audio_graph_init(&g_, frames_per_period);
48 [[nodiscard]]
int add_node(
const struct ove_audio_node_ops *ops,
49 void *ctx,
const char *name,
50 enum ove_audio_node_type type) {
51 return ove_audio_graph_add_node(&g_, ops, ctx, name, type);
55 [[nodiscard]]
int connect(
unsigned int from,
unsigned int to) {
56 return ove_audio_graph_connect(&g_, from, to);
61 return ove_audio_graph_build(&g_);
66 return ove_audio_graph_start(&g_);
71 return ove_audio_graph_stop(&g_);
76 return ove_audio_graph_process(&g_);
80 [[nodiscard]]
int get_stats(
struct ove_audio_graph_stats *stats)
const {
81 return ove_audio_graph_get_stats(&g_, stats);
87 return ove_audio_device_source(&g_, cfg, name);
91 [[nodiscard]]
int device_sink(
const struct ove_audio_device_cfg *cfg,
93 return ove_audio_device_sink(&g_, cfg, name);
97 struct ove_audio_graph *
raw() {
return &g_; }
105 static const struct ove_audio_node_ops ops = {
107 [](
void *,
const struct ove_audio_fmt *in_f,
108 struct ove_audio_fmt *out_f) ->
int {
109 if (in_f && out_f) *out_f = *in_f;
115 [](
void *ctx,
const struct ove_audio_buf *in,
116 struct ove_audio_buf *out) ->
int {
117 return static_cast<T*
>(ctx)->
process(in, out);
121 return ove_audio_graph_add_node(&g_, &ops, &node, name,
122 OVE_AUDIO_NODE_PROCESSOR);
126 struct ove_audio_graph g_;
C++ wrapper around ove_audio_graph.
Definition audio.hpp:30
int connect(unsigned int from, unsigned int to)
Connect two nodes (output of from to input of to).
Definition audio.hpp:55
int init(unsigned int frames_per_period)
Initialise the audio graph with the given period size.
Definition audio.hpp:40
int get_stats(struct ove_audio_graph_stats *stats) const
Query runtime statistics.
Definition audio.hpp:80
int build()
Finalize the graph topology.
Definition audio.hpp:60
struct ove_audio_graph * raw()
Access the underlying C graph struct.
Definition audio.hpp:97
int device_source(const struct ove_audio_device_cfg *cfg, const char *name)
Add an audio input device as a source node.
Definition audio.hpp:85
int device_sink(const struct ove_audio_device_cfg *cfg, const char *name)
Add an audio output device as a sink node.
Definition audio.hpp:91
int process()
Run one processing period through the graph.
Definition audio.hpp:75
int start()
Start audio processing.
Definition audio.hpp:65
int stop()
Stop audio processing.
Definition audio.hpp:70
int add_node(const struct ove_audio_node_ops *ops, void *ctx, const char *name, enum ove_audio_node_type type)
Add a processing node to the graph.
Definition audio.hpp:48
int add_processor(T &node, const char *name)
Definition audio.hpp:104
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.