[pulseaudio-discuss] [PATCH v2 12/25] echo-cancel: Fix a bad condition in webrtc sample rate selection

arun at accosted.net arun at accosted.net
Tue Dec 15 19:39:58 PST 2015


From: Arun Raghavan <git at arunraghavan.net>

The old logic would pick 8000 if the underlying sample rate was
16/32/48 kHz.
---
 src/modules/echo-cancel/webrtc.cc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
index b8781f4..4c8332f 100644
--- a/src/modules/echo-cancel/webrtc.cc
+++ b/src/modules/echo-cancel/webrtc.cc
@@ -116,16 +116,14 @@ static void pa_webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec
     play_ss->format = PA_SAMPLE_S16NE;
 
     /* AudioProcessing expects one of the following rates */
-    if (rec_ss->rate > 48000)
+    if (rec_ss->rate >= 48000)
         rec_ss->rate = 48000;
-    else if (rec_ss->rate > 32000 && rec_ss->rate < 48000)
+    else if (rec_ss->rate >= 32000)
         rec_ss->rate = 32000;
-    else if (rec_ss->rate > 16000 && rec_ss->rate < 32000)
+    else if (rec_ss->rate >= 16000)
         rec_ss->rate = 16000;
-    else if (rec_ss->rate != 8000)
-        rec_ss->rate = 8000;
     else
-        ; /* All good, rate is 8/16/32/48 kHz */
+        rec_ss->rate = 8000;
 
     /* In int16 mode, AudioProcessing will give us the same spec we give it */
     *out_ss = *rec_ss;
-- 
2.5.0



More information about the pulseaudio-discuss mailing list