[pulseaudio-discuss] [PATCH 3/3] echo-cancel: Warn on different sample rates for rec, play, out stream

Stefan Huber s.huber at bct-electronic.com
Thu Feb 7 05:40:07 PST 2013


The current echo-cancel framework does not support different sample
rates for the rec, play and out stream as it is assumed that the blocks
passed to the EC implementation's run() cover equal time spans. However,
pa__init() does not check that. Fix this.
---
 src/modules/echo-cancel/module-echo-cancel.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index a140902..4ee36eb 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -1743,12 +1743,26 @@ int pa__init(pa_module*m) {
     source_output_ss = source_ss;
     source_output_map = source_map;
 
+    if (sink_ss.rate != source_ss.rate) {
+        pa_log_info("Sample rates of play and out stream differ. Adjusting rate of play stream.");
+        sink_ss.rate = source_ss.rate;
+    }
+
     pa_assert(u->ec->init);
     if (!u->ec->init(u->core, u->ec, &source_output_ss, &source_output_map, &sink_ss, &sink_map, &source_ss, &source_map, &nframes, pa_modargs_get_value(ma, "aec_args", NULL))) {
         pa_log("Failed to init AEC engine");
         goto fail;
     }
 
+    if (source_output_ss.rate != source_ss.rate) {
+        pa_log_error("Sample rates of rec and out stream differ, which is not supported. Adjusting rate of rec stream.");
+        source_output_ss.rate = source_ss.rate;
+    }
+    if (sink_ss.rate != source_ss.rate) {
+        pa_log_error("Sample rates of play and out stream differ, which is not supported. Adjusting rate of play stream.");
+        sink_ss.rate = source_ss.rate;
+    }
+
     u->source_output_blocksize = nframes * pa_frame_size(&source_output_ss);
     u->source_blocksize = nframes * pa_frame_size(&source_ss);
     u->sink_blocksize = nframes * pa_frame_size(&sink_ss);
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list