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.
This commit is contained in:
Wim Taymans 2021-12-08 22:28:34 +01:00
parent db77f6d37d
commit 0d422f00dd

View file

@ -109,6 +109,15 @@
* *
*/ */
/**
* .--------. .---------. .--------. .----------. .-------.
* | source | --> | capture | --> | | --> | source | --> | app |
* '--------' '---------' | echo | '----------' '-------'
* | cancel |
* .--------. .---------. | | .----------. .--------.
* | app | --> | sink | --> | | --> | playback | --> | sink |
* '--------' '---------' '--------' '----------' '--------'
*/
#define NAME "echo-cancel" #define NAME "echo-cancel"
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); 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_queue_buffer(impl->playback, pout);
pw_stream_trigger_process(impl->playback);
/* Now run the canceller */ /* Now run the canceller */
echo_cancel_run(impl->aec_info, impl->aec, rec, play, out, size / sizeof(float)); 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); spa_ringbuffer_read_update(&impl->out_ring, oindex);
avail -= size; avail -= size;
} }
pw_stream_trigger_process(impl->source);
done: done:
impl->sink_ready = false; impl->sink_ready = false;
@ -689,7 +701,8 @@ static int setup_streams(struct impl *impl)
PW_DIRECTION_OUTPUT, PW_DIRECTION_OUTPUT,
PW_ID_ANY, PW_ID_ANY,
PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS, PW_STREAM_FLAG_RT_PROCESS |
PW_STREAM_FLAG_TRIGGER,
params, n_params)) < 0) params, n_params)) < 0)
return res; return res;
@ -706,7 +719,8 @@ static int setup_streams(struct impl *impl)
PW_ID_ANY, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS, PW_STREAM_FLAG_RT_PROCESS |
PW_STREAM_FLAG_TRIGGER,
params, n_params)) < 0) params, n_params)) < 0)
return res; return res;