summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun@arunraghavan.net>2017-03-09 09:58:23 +0530
committerArun Raghavan <arun@arunraghavan.net>2017-03-29 11:04:06 +0530
commit2c2ca1c949553b59c54431ec179b31a697004492 (patch)
tree3a40a6022e9da745b6961a462c17bbb33d3b79bb
parentf4f01f6833b30841e026febe0d831b7b3489b981 (diff)
echo-cancel: Try to minimise in-flight chunks in snapshot latency
We don't always know whether the in-flight memory chunks will be rendered or skipped (if the source is not in RUNNING). This can cause us to have an erroneous estimate of drift, particularly when the canceller starts. To avoid this, we explicitly flush out the send and receive sides of the message queue of audio chunks going from the sink to the source before trying to perform a resync.
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 14a148a3..4f80be40 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -689,8 +689,13 @@ static void do_resync(struct userdata *u) {
pa_log("Doing resync");
/* update our snapshot */
- source_output_snapshot_within_thread(u, &latency_snapshot);
+ /* 1. Get sink input latency snapshot, might cause buffers to be sent to source thread */
pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_LATENCY_SNAPSHOT, &latency_snapshot, 0, NULL);
+ /* 2. Pick up any in-flight buffers (and discard if needed) */
+ while (pa_asyncmsgq_process_one(u->asyncmsgq))
+ ;
+ /* 3. Now get the source output latency snapshot */
+ source_output_snapshot_within_thread(u, &latency_snapshot);
/* calculate drift between capture and playback */
diff_time = calc_diff(u, &latency_snapshot);