Change NetEq::GetAudio to use AudioFrame
With this change, NetEq now uses AudioFrame as output type, like the surrounding functions in ACM and VoiceEngine already do. The computational savings is probably slim, since one memcpy is removed while another one is added (both in AcmReceiver::GetAudio). More simplifications and clean-up will be done in AcmReceiver::GetAudio in future CLs. BUG=webrtc:5607 Review URL: https://codereview.webrtc.org/1750353002 Cr-Commit-Position: refs/heads/master@{#11874}
This commit is contained in:
committed by
Commit bot
parent
6459f84766
commit
6d8e011b64
@ -140,20 +140,29 @@ TEST(SyncBuffer, GetNextAudioInterleaved) {
|
||||
|
||||
// Read to interleaved output. Read in two batches, where each read operation
|
||||
// should automatically update the |net_index_| in the SyncBuffer.
|
||||
int16_t output[kChannels * kNewLen];
|
||||
// Note that |samples_read| is the number of samples read from each channel.
|
||||
// That is, the number of samples written to |output| is
|
||||
// |samples_read| * |kChannels|.
|
||||
size_t samples_read = sync_buffer.GetNextAudioInterleaved(kNewLen / 2,
|
||||
output);
|
||||
samples_read +=
|
||||
sync_buffer.GetNextAudioInterleaved(kNewLen / 2,
|
||||
&output[samples_read * kChannels]);
|
||||
EXPECT_EQ(kNewLen, samples_read);
|
||||
AudioFrame output1;
|
||||
sync_buffer.GetNextAudioInterleaved(kNewLen / 2, &output1);
|
||||
EXPECT_EQ(kChannels, output1.num_channels_);
|
||||
EXPECT_EQ(kNewLen / 2, output1.samples_per_channel_);
|
||||
|
||||
AudioFrame output2;
|
||||
sync_buffer.GetNextAudioInterleaved(kNewLen / 2, &output2);
|
||||
EXPECT_EQ(kChannels, output2.num_channels_);
|
||||
EXPECT_EQ(kNewLen / 2, output2.samples_per_channel_);
|
||||
|
||||
// Verify the data.
|
||||
int16_t* output_ptr = output;
|
||||
for (size_t i = 0; i < kNewLen; ++i) {
|
||||
int16_t* output_ptr = output1.data_;
|
||||
for (size_t i = 0; i < kNewLen / 2; ++i) {
|
||||
for (size_t channel = 0; channel < kChannels; ++channel) {
|
||||
EXPECT_EQ(new_data[channel][i], *output_ptr);
|
||||
++output_ptr;
|
||||
}
|
||||
}
|
||||
output_ptr = output2.data_;
|
||||
for (size_t i = kNewLen / 2; i < kNewLen; ++i) {
|
||||
for (size_t channel = 0; channel < kChannels; ++channel) {
|
||||
EXPECT_EQ(new_data[channel][i], *output_ptr);
|
||||
++output_ptr;
|
||||
|
||||
Reference in New Issue
Block a user