Skip to content

Commit e16d68a

Browse files
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. [email protected] 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
1 parent 8839fd6 commit e16d68a

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

webrtc/modules/audio_processing/audio_processing_impl.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,9 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
498498

499499
capture_audio_->CopyFrom(src, samples_per_channel, input_layout);
500500
RETURN_ON_ERR(ProcessStreamLocked());
501-
if (output_copy_needed(is_data_processed())) {
502-
capture_audio_->CopyTo(fwd_out_format_.samples_per_channel(),
503-
output_layout,
504-
dest);
505-
}
501+
capture_audio_->CopyTo(fwd_out_format_.samples_per_channel(),
502+
output_layout,
503+
dest);
506504

507505
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
508506
if (debug_file_->Open()) {

webrtc/modules/audio_processing/test/audio_processing_unittest.cc

+22
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,28 @@ TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) {
13441344
}
13451345
}
13461346

1347+
TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) {
1348+
// Test that ProcessStream copies input to output even with no processing.
1349+
const size_t kSamples = 80;
1350+
const int sample_rate = 8000;
1351+
const float src[kSamples] = {
1352+
-1.0f, 0.0f, 1.0f
1353+
};
1354+
float dest[kSamples] = {};
1355+
1356+
auto src_channels = &src[0];
1357+
auto dest_channels = &dest[0];
1358+
1359+
apm_.reset(AudioProcessing::Create());
1360+
EXPECT_NOERR(apm_->ProcessStream(
1361+
&src_channels, kSamples, sample_rate, LayoutFromChannels(1),
1362+
sample_rate, LayoutFromChannels(1), &dest_channels));
1363+
1364+
for (size_t i = 0; i < kSamples; ++i) {
1365+
EXPECT_EQ(src[i], dest[i]);
1366+
}
1367+
}
1368+
13471369
TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) {
13481370
EnableAllComponents();
13491371

0 commit comments

Comments
 (0)