aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeah <peah@webrtc.org>2015-12-16 02:02:20 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-16 10:02:26 +0000
commit66085beef83c790a69666b9be8a74bb2eee44fab (patch)
tree5f1983a44c6e0e6ef24c61c3780605a2f433f5d6
parent54999d411b97e3df54121e5f7bfb28846f3c8086 (diff)
downloadwebrtc-66085beef83c790a69666b9be8a74bb2eee44fab.tar.gz
Bugfix that fixes the error where the audio processing module is called
using the wrong sample rate for the render signal. The CL is basically a partial revert of the related changes done on output_mixer.cc in the CL https://codereview.webrtc.org/1234463003. The CL also reverts the removal of the input_sample_rate_hz() method that was removed as part of the CL https://codereview.webrtc.org/1379123002 (as it was at that point no longer used). It should be noted that this CL turns off the effect of the IntelligibilityEnhancer when the AudioFrame AudioProcessing APIs are used. While it may be possible to solve that by adding upsampling after the API call, that approach was discarded due to that: -That would add extra processing in the echo path, leading to possible AEC performance reduction. -That would add extra complexity for the mobile case. -That would only patch the intelligibility enhancer operation as the proper way to do such an operation is within APM. -The intelligibility enhancer is not active by default anywhere. BUG=webrtc:5237 Review URL: https://codereview.webrtc.org/1525173002 Cr-Commit-Position: refs/heads/master@{#11045}
-rw-r--r--talk/media/webrtc/fakewebrtcvoiceengine.h1
-rw-r--r--webrtc/modules/audio_processing/audio_processing_impl.cc6
-rw-r--r--webrtc/modules/audio_processing/audio_processing_impl.h1
-rw-r--r--webrtc/modules/audio_processing/include/audio_processing.h4
-rw-r--r--webrtc/voice_engine/output_mixer.cc23
-rw-r--r--webrtc/voice_engine/output_mixer.h1
6 files changed, 26 insertions, 10 deletions
diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h
index b7a7262af7..bf22a290b8 100644
--- a/talk/media/webrtc/fakewebrtcvoiceengine.h
+++ b/talk/media/webrtc/fakewebrtcvoiceengine.h
@@ -74,6 +74,7 @@ class FakeAudioProcessing : public webrtc::AudioProcessing {
experimental_ns_enabled_ = config.Get<webrtc::ExperimentalNs>().enabled;
}
+ WEBRTC_STUB_CONST(input_sample_rate_hz, ());
WEBRTC_STUB_CONST(proc_sample_rate_hz, ());
WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ());
WEBRTC_STUB_CONST(num_input_channels, ());
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index e99720ddb4..67ad266d50 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -501,6 +501,12 @@ void AudioProcessingImpl::SetExtraOptions(const Config& config) {
}
}
+int AudioProcessingImpl::input_sample_rate_hz() const {
+ // Accessed from outside APM, hence a lock is needed.
+ rtc::CritScope cs(&crit_capture_);
+ return formats_.api_format.input_stream().sample_rate_hz();
+}
+
int AudioProcessingImpl::proc_sample_rate_hz() const {
// Used as callback from submodules, hence locking is not allowed.
return capture_nonlocked_.fwd_proc_format.sample_rate_hz();
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h
index eb349769d0..87a145ab3c 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.h
+++ b/webrtc/modules/audio_processing/audio_processing_impl.h
@@ -81,6 +81,7 @@ class AudioProcessingImpl : public AudioProcessing {
void set_delay_offset_ms(int offset) override;
int delay_offset_ms() const override;
void set_stream_key_pressed(bool key_pressed) override;
+ int input_sample_rate_hz() const override;
// Render-side exclusive methods possibly running APM in a
// multi-threaded manner. Acquire the render lock.
diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h
index c8ddc6a483..5fcc4d4672 100644
--- a/webrtc/modules/audio_processing/include/audio_processing.h
+++ b/webrtc/modules/audio_processing/include/audio_processing.h
@@ -279,6 +279,10 @@ class AudioProcessing {
// ensures the options are applied immediately.
virtual void SetExtraOptions(const Config& config) = 0;
+ // TODO(peah): Remove after voice engine no longer requires it to resample
+ // the reverse stream to the forward rate.
+ virtual int input_sample_rate_hz() const = 0;
+
// TODO(ajm): Only intended for internal use. Make private and friend the
// necessary classes?
virtual int proc_sample_rate_hz() const = 0;
diff --git a/webrtc/voice_engine/output_mixer.cc b/webrtc/voice_engine/output_mixer.cc
index d46ee6296d..d3a4f7fc8f 100644
--- a/webrtc/voice_engine/output_mixer.cc
+++ b/webrtc/voice_engine/output_mixer.cc
@@ -517,8 +517,20 @@ OutputMixer::DoOperationsOnCombinedSignal(bool feed_data_to_apm)
}
// --- Far-end Voice Quality Enhancement (AudioProcessing Module)
- if (feed_data_to_apm)
- APMProcessReverseStream();
+ if (feed_data_to_apm) {
+ // Convert from mixing to AudioProcessing sample rate, similarly to how it
+ // is done on the send side. Downmix to mono.
+ AudioFrame frame;
+ frame.num_channels_ = 1;
+ frame.sample_rate_hz_ = _audioProcessingModulePtr->input_sample_rate_hz();
+ RemixAndResample(_audioFrame, &audioproc_resampler_, &frame);
+
+ if (_audioProcessingModulePtr->AnalyzeReverseStream(&frame) != 0) {
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
+ "AudioProcessingModule::AnalyzeReverseStream() => error");
+ RTC_DCHECK(false);
+ }
+ }
// --- External media processing
{
@@ -549,13 +561,6 @@ OutputMixer::DoOperationsOnCombinedSignal(bool feed_data_to_apm)
// Private methods
// ----------------------------------------------------------------------------
-void OutputMixer::APMProcessReverseStream() {
- if (_audioProcessingModulePtr->ProcessReverseStream(&_audioFrame) != 0) {
- WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1),
- "AudioProcessingModule::ProcessReverseStream() => error");
- }
-}
-
int
OutputMixer::InsertInbandDtmfTone()
{
diff --git a/webrtc/voice_engine/output_mixer.h b/webrtc/voice_engine/output_mixer.h
index 8c0a2de53b..c042a038dd 100644
--- a/webrtc/voice_engine/output_mixer.h
+++ b/webrtc/voice_engine/output_mixer.h
@@ -102,7 +102,6 @@ public:
private:
OutputMixer(uint32_t instanceId);
- void APMProcessReverseStream();
int InsertInbandDtmfTone();
// uses