From baca092ba5396ffec23e0763573ed4acacd55eaa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 19 Oct 2021 16:09:43 +0200 Subject: [PATCH] stream: emit the RequestProcess event Emit the RequestProcess event when pw_stream_trigger_process() was called but we are not the driver node. Fixes #1728 --- src/pipewire/stream.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 13ebd95c4..d56ed28cd 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -2192,6 +2192,18 @@ do_trigger_process(struct spa_loop *loop, return spa_node_call_ready(&impl->callbacks, res); } +static int trigger_request_process(struct stream *impl) +{ + uint8_t buffer[1024]; + struct spa_pod_builder b = { 0 }; + + spa_pod_builder_init(&b, buffer, sizeof(buffer)); + spa_node_emit_event(&impl->hooks, + spa_pod_builder_add_object(&b, + SPA_TYPE_EVENT_Node, SPA_NODE_EVENT_RequestProcess)); + return 0; +} + SPA_EXPORT int pw_stream_trigger_process(struct pw_stream *stream) { @@ -2203,16 +2215,16 @@ int pw_stream_trigger_process(struct pw_stream *stream) /* flag to check for old or new behaviour */ impl->using_trigger = true; - if (!impl->driving) - return -EINVAL; - - if (impl->direction == SPA_DIRECTION_OUTPUT && - !impl->process_rt) { - pw_loop_invoke(impl->context->main_loop, - do_call_process, 1, NULL, 0, false, impl); + if (!impl->driving) { + res = trigger_request_process(impl); + } else { + if (impl->direction == SPA_DIRECTION_OUTPUT && + !impl->process_rt) { + pw_loop_invoke(impl->context->main_loop, + do_call_process, 1, NULL, 0, false, impl); + } + res = pw_loop_invoke(impl->context->data_loop, + do_trigger_process, 1, NULL, 0, false, impl); } - res = pw_loop_invoke(impl->context->data_loop, - do_trigger_process, 1, NULL, 0, false, impl); - return res; }