summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <git@arunraghavan.net>2016-02-17 19:46:57 +0530
committerArun Raghavan <git@arunraghavan.net>2016-02-25 09:09:05 +0530
commit23ef4911227e69fb0c289a991e2b5d61bb1b0dd6 (patch)
treee8f5018ab90fdc8fc58d63dbc8d9526f1b3414a8
parentd777838fbb1a8e1f012e249bb1a0816d9141dd45 (diff)
echo-cancel: Express restrictions correctly on webrtc AEC stream config
In the refactoring, I'm expressing the constraints in what I see to be a more natural way -- rec_ss expresses what we're feeding the canceller, so it makes sense to apply the constraints on what the canceller accepts there. This then propagates to the output spec. This also exposes the range of sample rates that the library actually supports (8, 16, 32 and 48 kHz).
-rw-r--r--src/modules/echo-cancel/webrtc.cc35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/modules/echo-cancel/webrtc.cc b/src/modules/echo-cancel/webrtc.cc
index 7e4e95239..0d357fb39 100644
--- a/src/modules/echo-cancel/webrtc.cc
+++ b/src/modules/echo-cancel/webrtc.cc
@@ -78,6 +78,31 @@ static int routing_mode_from_string(const char *rmode) {
return -1;
}
+void pa_webrtc_ec_fixate_spec(pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+ pa_sample_spec *play_ss, pa_channel_map *play_map,
+ pa_sample_spec *out_ss, pa_channel_map *out_map)
+{
+ rec_ss->format = PA_SAMPLE_S16NE;
+ play_ss->format = PA_SAMPLE_S16NE;
+
+ /* AudioProcessing expects one of the following rates */
+ if (rec_ss->rate >= 48000)
+ rec_ss->rate = 48000;
+ else if (rec_ss->rate >= 32000)
+ rec_ss->rate = 32000;
+ else if (rec_ss->rate >= 16000)
+ rec_ss->rate = 16000;
+ else
+ rec_ss->rate = 8000;
+
+ /* In int16 mode, AudioProcessing will give us the same spec we give it */
+ *out_ss = *rec_ss;
+ *out_map = *rec_map;
+
+ /* Playback stream rate needs to be the same as capture */
+ play_ss->rate = rec_ss->rate;
+}
+
bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_sample_spec *rec_ss, pa_channel_map *rec_map,
pa_sample_spec *play_ss, pa_channel_map *play_map,
@@ -176,15 +201,9 @@ bool pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
if (intelligibility)
pa_log_warn("The intelligibility enhancer is not currently supported");
- apm = webrtc::AudioProcessing::Create(config);
+ pa_webrtc_ec_fixate_spec(rec_ss, rec_map, play_ss, play_map, out_ss, out_map);
- out_ss->format = PA_SAMPLE_S16NE;
- *play_ss = *out_ss;
- /* FIXME: the implementation actually allows a different number of
- * source/sink channels. Do we want to support that? */
- *play_map = *out_map;
- *rec_ss = *out_ss;
- *rec_map = *out_map;
+ apm = webrtc::AudioProcessing::Create(config);
pconfig = {
webrtc::StreamConfig(rec_ss->rate, rec_ss->channels, false), /* input stream */