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

Unified Diff: media/renderers/audio_renderer_impl_unittest.cc

Issue 2536013002: Fix implicit channel layout configurations at non-1.0 playback rates. (Closed)
Patch Set: Created 4 years, 1 month 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/renderers/audio_renderer_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/audio_renderer_impl_unittest.cc
diff --git a/media/renderers/audio_renderer_impl_unittest.cc b/media/renderers/audio_renderer_impl_unittest.cc
index 9bf367d7b6e5ce4b7c8c7aa941958cd68d2767cc..db031e967de60a35243b2b03ecdfe505cf11bf62 100644
--- a/media/renderers/audio_renderer_impl_unittest.cc
+++ b/media/renderers/audio_renderer_impl_unittest.cc
@@ -83,18 +83,9 @@ class AudioRendererImplTest : public ::testing::Test, public RendererClient {
Unencrypted());
demuxer_stream_.set_audio_decoder_config(audio_config);
- // Used to save callbacks and run them at a later time.
- EXPECT_CALL(*decoder_, Decode(_, _))
- .WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder));
- EXPECT_CALL(*decoder_, Reset(_))
- .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder));
+ ConfigureDecoder();
+ ConfigureDemuxerStream(true);
- // Mock out demuxer reads.
- EXPECT_CALL(demuxer_stream_, Read(_)).WillRepeatedly(
- RunCallback<0>(DemuxerStream::kOk,
- scoped_refptr<DecoderBuffer>(new DecoderBuffer(0))));
- EXPECT_CALL(demuxer_stream_, SupportsConfigChanges())
- .WillRepeatedly(Return(true));
AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
kChannelLayout,
kOutputSamplesPerSecond,
@@ -113,19 +104,37 @@ class AudioRendererImplTest : public ::testing::Test, public RendererClient {
SCOPED_TRACE("~AudioRendererImplTest()");
}
+ // Used to save callbacks and run them at a later time.
+ void ConfigureDecoder() {
+ EXPECT_CALL(*decoder_, Decode(_, _))
+ .WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder));
+ EXPECT_CALL(*decoder_, Reset(_))
+ .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder));
+ }
+
+ // Mock out demuxer reads.
+ void ConfigureDemuxerStream(bool supports_config_changes) {
+ EXPECT_CALL(demuxer_stream_, Read(_))
+ .WillRepeatedly(
+ RunCallback<0>(DemuxerStream::kOk,
+ scoped_refptr<DecoderBuffer>(new DecoderBuffer(0))));
+ EXPECT_CALL(demuxer_stream_, SupportsConfigChanges())
+ .WillRepeatedly(Return(supports_config_changes));
+ }
+
// Reconfigures a renderer without config change support using given params.
void ConfigureBasicRenderer(const AudioParameters& params) {
hardware_params_ = params;
sink_ = new FakeAudioRendererSink(hardware_params_);
decoder_ = new MockAudioDecoder();
+ ConfigureDecoder();
ScopedVector<AudioDecoder> decoders;
decoders.push_back(decoder_);
renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(),
sink_.get(), std::move(decoders),
new MediaLog()));
testing::Mock::VerifyAndClearExpectations(&demuxer_stream_);
- EXPECT_CALL(demuxer_stream_, SupportsConfigChanges())
- .WillRepeatedly(Return(false));
+ ConfigureDemuxerStream(false);
}
// Reconfigures a renderer with config change support using given params.
@@ -134,14 +143,14 @@ class AudioRendererImplTest : public ::testing::Test, public RendererClient {
hardware_params_ = hardware_params;
sink_ = new FakeAudioRendererSink(hardware_params_);
decoder_ = new MockAudioDecoder();
+ ConfigureDecoder();
ScopedVector<AudioDecoder> decoders;
decoders.push_back(decoder_);
renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(),
sink_.get(), std::move(decoders),
new MediaLog()));
testing::Mock::VerifyAndClearExpectations(&demuxer_stream_);
- EXPECT_CALL(demuxer_stream_, SupportsConfigChanges())
- .WillRepeatedly(Return(true));
+ ConfigureDemuxerStream(true);
}
void ExpectUnsupportedAudioDecoder() {
@@ -389,19 +398,13 @@ class AudioRendererImplTest : public ::testing::Test, public RendererClient {
return renderer_->CurrentMediaTime();
}
- std::vector<bool> channel_mask() const { return renderer_->channel_mask_; }
+ std::vector<bool> channel_mask() const {
+ CHECK(renderer_->algorithm_);
+ return renderer_->algorithm_->channel_mask_for_testing();
+ }
bool ended() const { return ended_; }
- // Fixture members.
- AudioParameters hardware_params_;
- base::MessageLoop message_loop_;
- std::unique_ptr<AudioRendererImpl> renderer_;
- scoped_refptr<FakeAudioRendererSink> sink_;
- base::SimpleTestTickClock* tick_clock_;
- PipelineStatistics last_statistics_;
-
- private:
void DecodeDecoder(const scoped_refptr<DecoderBuffer>& buffer,
const AudioDecoder::DecodeCB& decode_cb) {
// TODO(scherkus): Make this a DCHECK after threading semantics are fixed.
@@ -445,6 +448,14 @@ class AudioRendererImplTest : public ::testing::Test, public RendererClient {
base::RunLoop().RunUntilIdle();
}
+ // Fixture members.
+ AudioParameters hardware_params_;
+ base::MessageLoop message_loop_;
+ std::unique_ptr<AudioRendererImpl> renderer_;
+ scoped_refptr<FakeAudioRendererSink> sink_;
+ base::SimpleTestTickClock* tick_clock_;
+ PipelineStatistics last_statistics_;
+
MockDemuxerStream demuxer_stream_;
MockAudioDecoder* decoder_;
@@ -599,7 +610,6 @@ TEST_F(AudioRendererImplTest, CapacityAppropriateForHardware) {
// Verify that the proper reduced search space is configured for playback rate
// changes when upmixing is applied to the input.
TEST_F(AudioRendererImplTest, ChannelMask) {
- Initialize();
AudioParameters hw_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
CHANNEL_LAYOUT_7_1, kOutputSamplesPerSecond,
SampleFormatToBytesPerChannel(kSampleFormat) * 8,
@@ -609,17 +619,33 @@ TEST_F(AudioRendererImplTest, ChannelMask) {
CHANNEL_LAYOUT_STEREO, kOutputSamplesPerSecond,
SampleFormatToBytesPerChannel(kSampleFormat) * 8, 1024),
hw_params);
- std::vector<bool> mask = channel_mask();
- EXPECT_TRUE(mask.empty());
Initialize();
- mask = channel_mask();
+ std::vector<bool> mask = channel_mask();
EXPECT_FALSE(mask.empty());
+ ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
for (int ch = 0; ch < hw_params.channels(); ++ch) {
if (ch > 1)
ASSERT_FALSE(mask[ch]);
else
ASSERT_TRUE(mask[ch]);
}
+
+ renderer_->SetMediaTime(base::TimeDelta());
+ renderer_->StartPlaying();
+ WaitForPendingRead();
+
+ // Force a channel configuration change.
+ scoped_refptr<AudioBuffer> buffer = MakeAudioBuffer<float>(
+ kSampleFormat, hw_params.channel_layout(), hw_params.channels(),
+ kInputSamplesPerSecond, 1.0f, 0.0f, 256, base::TimeDelta());
+ DeliverBuffer(DecodeStatus::OK, buffer);
+
+ // All channels should now be enabled.
+ mask = channel_mask();
+ EXPECT_FALSE(mask.empty());
+ ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
+ for (int ch = 0; ch < hw_params.channels(); ++ch)
+ ASSERT_TRUE(mask[ch]);
}
TEST_F(AudioRendererImplTest, Underflow_Flush) {
« no previous file with comments | « media/renderers/audio_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698