From d6e84d9d13d9cf9f5ba86c6235576463cff0811b Mon Sep 17 00:00:00 2001 From: "mgraczyk@chromium.org" Date: Wed, 14 Jan 2015 01:33:54 +0000 Subject: [PATCH] Always copy processed audio to output buffer in ProcessStream. In the old AudioFrame ProcessStream API, input and output buffers were shared. Now that the buffers are distinct, the input must be copied to the output even when no processing occurred. R=andrew@webrtc.org Committed: https://code.google.com/p/webrtc/source/detail?r=78de5010d167d1e375e05d26177aad43c2e2de08 Review URL: https://webrtc-codereview.appspot.com/41459004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8052 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_processing/audio_processing_impl.cc | 8 +++---- .../test/audio_processing_unittest.cc | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 0063608acd..92e63f19b8 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -498,11 +498,9 @@ int AudioProcessingImpl::ProcessStream(const float* const* src, capture_audio_->CopyFrom(src, samples_per_channel, input_layout); RETURN_ON_ERR(ProcessStreamLocked()); - if (output_copy_needed(is_data_processed())) { - capture_audio_->CopyTo(fwd_out_format_.samples_per_channel(), - output_layout, - dest); - } + capture_audio_->CopyTo(fwd_out_format_.samples_per_channel(), + output_layout, + dest); #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP if (debug_file_->Open()) { diff --git a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc index 53c0a320c3..217ffaef0a 100644 --- a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc +++ b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc @@ -1344,6 +1344,28 @@ TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { } } +TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) { + // Test that ProcessStream copies input to output even with no processing. + const size_t kSamples = 80; + const int sample_rate = 8000; + const float src[kSamples] = { + -1.0f, 0.0f, 1.0f + }; + float dest[kSamples] = {}; + + auto src_channels = &src[0]; + auto dest_channels = &dest[0]; + + apm_.reset(AudioProcessing::Create()); + EXPECT_NOERR(apm_->ProcessStream( + &src_channels, kSamples, sample_rate, LayoutFromChannels(1), + sample_rate, LayoutFromChannels(1), &dest_channels)); + + for (size_t i = 0; i < kSamples; ++i) { + EXPECT_EQ(src[i], dest[i]); + } +} + TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { EnableAllComponents();