From 9dc20765e115a942ecad4dce900aec77b91ec8c1 Mon Sep 17 00:00:00 2001 From: Frank Krick Date: Sun, 10 Aug 2025 19:31:22 -0400 Subject: [PATCH] Add stream for control - 1 --- src/modules/module-filter-chain.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index 6c2f16200..8381e18a1 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -1176,6 +1176,10 @@ struct impl { struct spa_hook playback_listener; struct spa_audio_info_raw playback_info; + struct pw_properties *control_props; + struct pw_stream *control; + struct spa_hook control_listener; + struct spa_audio_info_raw info; struct spa_io_position *position; @@ -1219,6 +1223,23 @@ static void capture_process(void *d) } } +static void control_process(void *d) +{ + struct impl *impl = d; + int res; + if ((res = pw_stream_trigger_process(impl->playback)) < 0) { + pw_log_debug("playback trigger error: %s", spa_strerror(res)); + while (true) { + struct pw_buffer *t; + if ((t = pw_stream_dequeue_buffer(impl->control)) == NULL) + break; + /* playback part is not ready, consume, discard and recycle + * the capture buffers */ + pw_stream_queue_buffer(impl->control, t); + } + } +} + static void playback_process(void *d) { struct impl *impl = d; @@ -1578,6 +1599,15 @@ static const struct pw_stream_events out_stream_events = { .param_changed = playback_param_changed, }; +static const struct pw_stream_events control_stream_events = { + PW_VERSION_STREAM_EVENTS, + .destroy = NULL, + .process = control_process, + .io_changed = NULL, + .state_changed = NULL, + .param_changed = NULL, +}; + static int setup_streams(struct impl *impl) { int res; @@ -1587,6 +1617,16 @@ static int setup_streams(struct impl *impl) struct spa_pod_dynamic_builder b; struct spa_filter_graph *graph = impl->graph; + impl->control = pw_stream_new(impl->core, + "filter control", impl->capture_props); + impl->control_props = NULL; + if (impl->control == NULL) + return -errno; + + pw_stream_add_listener(impl->control, + &impl->control_listener, + &control_stream_events, impl); + impl->capture = pw_stream_new(impl->core, "filter capture", impl->capture_props); impl->capture_props = NULL;