[PATCH v3 16/24] echo-cancel: Make webrtc AGC start volume a modarg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Arun Raghavan <git@xxxxxxxxxxxxxxxx>

Allows for tuning based on the target hardware.
---
 src/modules/echo-cancel/webrtc.cc | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
index 395d31e..ec0a383 100644
--- a/src/modules/echo-cancel/webrtc.cc
+++ b/src/modules/echo-cancel/webrtc.cc
@@ -51,10 +51,10 @@ PA_C_DECL_END
 #define DEFAULT_EXTENDED_FILTER false
 #define DEFAULT_INTELLIGIBILITY_ENHANCER false
 #define DEFAULT_EXPERIMENTAL_AGC false
+#define DEFAULT_AGC_START_VOLUME 85
 #define DEFAULT_TRACE false
 
 #define WEBRTC_AGC_MAX_VOLUME 255
-#define WEBRTC_AGC_START_VOLUME 85
 
 static const char* const valid_modargs[] = {
     "high_pass_filter",
@@ -69,6 +69,7 @@ static const char* const valid_modargs[] = {
     "extended_filter",
     "intelligibility_enhancer",
     "experimental_agc",
+    "agc_start_volume",
     "trace",
     NULL
 };
@@ -147,6 +148,7 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
     webrtc::Config config;
     bool hpf, ns, agc, dgc, mobile, cn, vad, ext_filter, intelligibility, experimental_agc;
     int rm = -1;
+    uint32_t agc_start_volume;
     pa_modargs *ma;
 
     if (!(ma = pa_modargs_new(args, valid_modargs))) {
@@ -242,12 +244,23 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
         goto fail;
     }
 
+    agc_start_volume = DEFAULT_AGC_START_VOLUME;
+    if (pa_modargs_get_value_u32(ma, "agc_start_volume", &agc_start_volume) < 0) {
+        pa_log("Failed to parse agc_start_volume value");
+        goto fail;
+    }
+    if (agc_start_volume > WEBRTC_AGC_MAX_VOLUME) {
+        pa_log("AGC start volume must not exceed %u", WEBRTC_AGC_MAX_VOLUME);
+        goto fail;
+    }
+    ec->params.webrtc.agc_start_volume = agc_start_volume;
+
     if (ext_filter)
         config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(true));
     if (intelligibility)
         config.Set<webrtc::Intelligibility>(new webrtc::Intelligibility(true));
     if (experimental_agc)
-        config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(true, WEBRTC_AGC_START_VOLUME));
+        config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(true, ec->params.webrtc.agc_start_volume));
 
     ec->params.webrtc.trace = DEFAULT_TRACE;
     if (pa_modargs_get_value_boolean(ma, "trace", &ec->params.webrtc.trace) < 0) {
@@ -381,7 +394,7 @@ void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out
              * needed to make sure that there's enough energy in the capture
              * signal for the AGC to work */
             ec->params.webrtc.first = false;
-            new_volume = WEBRTC_AGC_START_VOLUME;
+            new_volume = ec->params.webrtc.agc_start_volume;
         } else {
             new_volume = apm->gain_control()->stream_analog_level();
         }
-- 
2.5.0



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux