From ce4d91527a2cfaca3a8581ae4d5883fd63a346f9 Mon Sep 17 00:00:00 2001 From: peah Date: Fri, 19 May 2017 01:28:05 -0700 Subject: [PATCH] Avoid render resampling when there is no need for render signal analysis. This CL adjusts the render processing rate such to avoid resampling of the render signal when that is not needed. Note that to avoid acquiring more locks than needed, this should be achieved during initialization. BUG=webrtc:7667 Review-Url: https://codereview.webrtc.org/2887693002 Cr-Commit-Position: refs/heads/master@{#18207} --- .../audio_processing/audio_processing_impl.cc | 14 ++++++++++++-- .../audio_processing/audio_processing_unittest.cc | 2 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 756cc0cca5..961d9a47b0 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -471,6 +471,7 @@ int AudioProcessingImpl::InitializeLocked() { render_.render_audio.reset(nullptr); render_.render_converter.reset(nullptr); } + capture_.capture_audio.reset( new AudioBuffer(formats_.api_format.input_stream().num_frames(), formats_.api_format.input_stream().num_channels(), @@ -596,7 +597,13 @@ int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { // Always downmix the render stream to mono for analysis. This has been // demonstrated to work well for AEC in most practical scenarios. - formats_.render_processing_format = StreamConfig(render_processing_rate, 1); + if (submodule_states_.RenderMultiBandSubModulesActive()) { + formats_.render_processing_format = StreamConfig(render_processing_rate, 1); + } else { + formats_.render_processing_format = StreamConfig( + formats_.api_format.reverse_input_stream().sample_rate_hz(), + formats_.api_format.reverse_input_stream().num_channels()); + } if (capture_nonlocked_.capture_processing_format.sample_rate_hz() == kSampleRate32kHz || @@ -1460,7 +1467,10 @@ int AudioProcessingImpl::ProcessRenderStreamLocked() { } #endif - QueueBandedRenderAudio(render_buffer); + if (submodule_states_.RenderMultiBandSubModulesActive()) { + QueueBandedRenderAudio(render_buffer); + } + // TODO(peah): Perform the queueing ínside QueueRenderAudiuo(). if (private_submodules_->echo_canceller3) { private_submodules_->echo_canceller3->AnalyzeRender(render_buffer); diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc index c56a57b4c3..4d97904c68 100644 --- a/webrtc/modules/audio_processing/audio_processing_unittest.cc +++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc @@ -862,8 +862,6 @@ TEST_F(ApmTest, ChannelsInt16Interface) { for (size_t i = 1; i < 4; i++) { TestChangingChannelsInt16Interface(i, kNoErr); EXPECT_EQ(i, apm_->num_input_channels()); - // We always force the number of reverse channels used for processing to 1. - EXPECT_EQ(1u, apm_->num_reverse_channels()); } }