summaryrefslogtreecommitdiffstats
path: root/src/modules/echo-cancel/module-echo-cancel.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2010-09-09 12:39:15 +0200
committerColin Guthrie <cguthrie@mandriva.org>2010-09-09 17:03:45 +0100
commit7b873785ca40c7d1d3109f8cc8202b996ebe1522 (patch)
tree7121abc26acd6498eb072c6ab35c8c538b70d24e /src/modules/echo-cancel/module-echo-cancel.c
parentc47d6896136e04dff538240ae29fd0cac021b25b (diff)
echo-cancel: improve accuracy
Make the echo canceler drift up to 1ms now that things are more accurate. Add 10 samples of headroom to allow for timing inaccuracies.
Diffstat (limited to 'src/modules/echo-cancel/module-echo-cancel.c')
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 4df77c30..467e2160 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -295,7 +295,7 @@ static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct tim
new_rate = base_rate;
}
else {
- if (diff_time > 4000) {
+ if (diff_time > 1000) {
/* diff too big, quickly adjust */
pa_asyncmsgq_post(u->asyncmsgq, PA_MSGOBJECT(u->source_output), SOURCE_OUTPUT_MESSAGE_APPLY_DIFF_TIME,
NULL, diff_time, NULL, NULL);
@@ -594,6 +594,10 @@ static void apply_diff_time(struct userdata *u, int64_t diff_time) {
diff = pa_usec_to_bytes (-diff_time, &u->source_output->sample_spec);
if (diff > 0) {
+ /* add some extra safety samples to compensate for jitter in the
+ * timings */
+ diff += 10 * pa_frame_size (&u->source_output->sample_spec);
+
pa_log_info("Playback after capture (%lld), drop sink %lld", (long long) diff_time, (long long) diff);
u->sink_skip = diff;