From 0d422f00dde625a8017cb91149ba849b4c65a6ec Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 Dec 2021 22:28:34 +0100 Subject: [PATCH] module-echo-cancel: schedule source and playback last Use the new TRIGGER flag on the stream to ensure that the source and playback streams only get scheduled after we process their input streams, the sink and capture. --- src/modules/module-echo-cancel.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/module-echo-cancel.c b/src/modules/module-echo-cancel.c index 048dce702..0c0a670a3 100644 --- a/src/modules/module-echo-cancel.c +++ b/src/modules/module-echo-cancel.c @@ -109,6 +109,15 @@ * */ +/** + * .--------. .---------. .--------. .----------. .-------. + * | source | --> | capture | --> | | --> | source | --> | app | + * '--------' '---------' | echo | '----------' '-------' + * | cancel | + * .--------. .---------. | | .----------. .--------. + * | app | --> | sink | --> | | --> | playback | --> | sink | + * '--------' '---------' '--------' '----------' '--------' + */ #define NAME "echo-cancel" PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); @@ -255,6 +264,8 @@ static void process(struct impl *impl) pw_stream_queue_buffer(impl->playback, pout); + pw_stream_trigger_process(impl->playback); + /* Now run the canceller */ echo_cancel_run(impl->aec_info, impl->aec, rec, play, out, size / sizeof(float)); @@ -309,6 +320,7 @@ static void process(struct impl *impl) spa_ringbuffer_read_update(&impl->out_ring, oindex); avail -= size; } + pw_stream_trigger_process(impl->source); done: impl->sink_ready = false; @@ -689,7 +701,8 @@ static int setup_streams(struct impl *impl) PW_DIRECTION_OUTPUT, PW_ID_ANY, PW_STREAM_FLAG_MAP_BUFFERS | - PW_STREAM_FLAG_RT_PROCESS, + PW_STREAM_FLAG_RT_PROCESS | + PW_STREAM_FLAG_TRIGGER, params, n_params)) < 0) return res; @@ -706,7 +719,8 @@ static int setup_streams(struct impl *impl) PW_ID_ANY, PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | - PW_STREAM_FLAG_RT_PROCESS, + PW_STREAM_FLAG_RT_PROCESS | + PW_STREAM_FLAG_TRIGGER, params, n_params)) < 0) return res;