[pulseaudio-discuss] [PATCH] echo-cancel: Remove dead code

Peter Meerwald pmeerw at pmeerw.net
Wed May 20 16:45:28 PDT 2015


From: Peter Meerwald <p.meerwald at bct-electronic.com>

base_rate equals new_rate, so assign to new_rate directly and
drop dead code (and comments)

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/modules/echo-cancel/module-echo-cancel.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 57309b1..58104e8 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -334,9 +334,8 @@ static int64_t calc_diff(struct userdata *u, struct snapshot *snapshot) {
 /* Called from main context */
 static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct timeval *t, void *userdata) {
     struct userdata *u = userdata;
-    uint32_t old_rate, base_rate, new_rate;
+    uint32_t old_rate, new_rate;
     int64_t diff_time;
-    /*size_t fs*/
     struct snapshot latency_snapshot;
 
     pa_assert(u);
@@ -354,17 +353,14 @@ static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct tim
     /* calculate drift between capture and playback */
     diff_time = calc_diff(u, &latency_snapshot);
 
-    /*fs = pa_frame_size(&u->source_output->sample_spec);*/
     old_rate = u->sink_input->sample_spec.rate;
-    base_rate = u->source_output->sample_spec.rate;
+    new_rate = u->source_output->sample_spec.rate;
 
     if (diff_time < 0) {
         /* recording before playback, we need to adjust quickly. The echo
          * canceller does not work in this case. */
         pa_asyncmsgq_post(u->asyncmsgq, PA_MSGOBJECT(u->source_output), SOURCE_OUTPUT_MESSAGE_APPLY_DIFF_TIME,
             NULL, diff_time, NULL, NULL);
-        /*new_rate = base_rate - ((pa_usec_to_bytes(-diff_time, &u->source_output->sample_spec) / fs) * PA_USEC_PER_SEC) / u->adjust_time;*/
-        new_rate = base_rate;
     }
     else {
         if (diff_time > u->adjust_threshold) {
@@ -372,18 +368,8 @@ static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct tim
             pa_asyncmsgq_post(u->asyncmsgq, PA_MSGOBJECT(u->source_output), SOURCE_OUTPUT_MESSAGE_APPLY_DIFF_TIME,
                 NULL, diff_time, NULL, NULL);
         }
-
-        /* recording behind playback, we need to slowly adjust the rate to match */
-        /*new_rate = base_rate + ((pa_usec_to_bytes(diff_time, &u->source_output->sample_spec) / fs) * PA_USEC_PER_SEC) / u->adjust_time;*/
-
-        /* assume equal samplerates for now */
-        new_rate = base_rate;
     }
 
-    /* make sure we don't make too big adjustments because that sounds horrible */
-    if (new_rate > base_rate * 1.1 || new_rate < base_rate * 0.9)
-        new_rate = base_rate;
-
     if (new_rate != old_rate) {
         pa_log_info("Old rate %lu Hz, new rate %lu Hz", (unsigned long) old_rate, (unsigned long) new_rate);
 
-- 
1.9.1



More information about the pulseaudio-discuss mailing list