Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: media/filters/audio_renderer_algorithm_unittest.cc

Issue 2541873005: Roll up of playback rate efficiency improvements for M56. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/audio_renderer_algorithm.cc ('k') | media/filters/wsola_internals.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_algorithm_unittest.cc
diff --git a/media/filters/audio_renderer_algorithm_unittest.cc b/media/filters/audio_renderer_algorithm_unittest.cc
index 53483f6d4e0832e503bec3405fdf29628add96ed..7cf6cb6e0a34aa510296e99b9fb5c5400b035f6d 100644
--- a/media/filters/audio_renderer_algorithm_unittest.cc
+++ b/media/filters/audio_renderer_algorithm_unittest.cc
@@ -83,13 +83,24 @@ class AudioRendererAlgorithmTest : public testing::Test {
~AudioRendererAlgorithmTest() override {}
void Initialize() {
- Initialize(CHANNEL_LAYOUT_STEREO, kSampleFormatS16, 3000, 300);
+ Initialize(CHANNEL_LAYOUT_STEREO, kSampleFormatS16, kSamplesPerSecond,
+ kSamplesPerSecond / 10);
}
void Initialize(ChannelLayout channel_layout,
SampleFormat sample_format,
int samples_per_second,
int frames_per_buffer) {
+ Initialize(
+ channel_layout, sample_format, samples_per_second, frames_per_buffer,
+ std::vector<bool>(ChannelLayoutToChannelCount(channel_layout), true));
+ }
+
+ void Initialize(ChannelLayout channel_layout,
+ SampleFormat sample_format,
+ int samples_per_second,
+ int frames_per_buffer,
+ std::vector<bool> channel_mask) {
channels_ = ChannelLayoutToChannelCount(channel_layout);
samples_per_second_ = samples_per_second;
channel_layout_ = channel_layout;
@@ -99,6 +110,7 @@ class AudioRendererAlgorithmTest : public testing::Test {
channel_layout, samples_per_second,
bytes_per_sample_ * 8, frames_per_buffer);
algorithm_.Initialize(params);
+ algorithm_.SetChannelMask(std::move(channel_mask));
FillAlgorithmQueue();
}
@@ -687,4 +699,39 @@ TEST_F(AudioRendererAlgorithmTest, FillBufferOffset) {
}
}
+TEST_F(AudioRendererAlgorithmTest, FillBuffer_ChannelMask) {
+ // Setup a quad channel layout where even channels are always muted.
+ Initialize(CHANNEL_LAYOUT_QUAD, kSampleFormatS16, 44100, 441,
+ {true, false, true, false});
+
+ std::unique_ptr<AudioBus> bus = AudioBus::Create(channels_, kFrameSize);
+ int frames_filled = algorithm_.FillBuffer(bus.get(), 0, kFrameSize, 2.0);
+ ASSERT_GT(frames_filled, 0);
+
+ // Verify the channels are muted appropriately; even though the created buffer
+ // actually has audio data in it.
+ for (int ch = 0; ch < bus->channels(); ++ch) {
+ double sum = 0;
+ for (int i = 0; i < bus->frames(); ++i)
+ sum += bus->channel(ch)[i];
+ if (ch % 2 == 1)
+ ASSERT_EQ(sum, 0);
+ else
+ ASSERT_NE(sum, 0);
+ }
+
+ // Update the channel mask and verify it's reflected correctly.
+ algorithm_.SetChannelMask({true, true, true, true});
+ frames_filled = algorithm_.FillBuffer(bus.get(), 0, kFrameSize, 2.0);
+ ASSERT_GT(frames_filled, 0);
+
+ // Verify no channels are muted now.
+ for (int ch = 0; ch < bus->channels(); ++ch) {
+ double sum = 0;
+ for (int i = 0; i < bus->frames(); ++i)
+ sum += bus->channel(ch)[i];
+ ASSERT_NE(sum, 0);
+ }
+}
+
} // namespace media
« no previous file with comments | « media/filters/audio_renderer_algorithm.cc ('k') | media/filters/wsola_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698