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

Unified Diff: media/filters/audio_renderer_impl_unittest.cc

Issue 177333003: Add support for midstream audio configuration changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ABS
Patch Set: Created 6 years, 9 months 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
Index: media/filters/audio_renderer_impl_unittest.cc
diff --git a/media/filters/audio_renderer_impl_unittest.cc b/media/filters/audio_renderer_impl_unittest.cc
index 965e5cfac6f5e44e95f7edc0be9df2f0c8f0164a..393b103e38fab8f4d3cacb8fd8ece1f553d625dc 100644
--- a/media/filters/audio_renderer_impl_unittest.cc
+++ b/media/filters/audio_renderer_impl_unittest.cc
@@ -11,6 +11,7 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "media/base/audio_buffer.h"
+#include "media/base/audio_hardware_config.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/fake_audio_renderer_sink.h"
#include "media/base/gmock_callback_support.h"
@@ -51,7 +52,8 @@ class AudioRendererImplTest : public ::testing::Test {
public:
// Give the decoder some non-garbage media properties.
AudioRendererImplTest()
- : needs_stop_(true),
+ : hardware_config_(AudioParameters(), AudioParameters()),
+ needs_stop_(true),
demuxer_stream_(DemuxerStream::AUDIO),
decoder_(new MockAudioDecoder()) {
AudioDecoderConfig audio_config(kCodec,
@@ -73,18 +75,16 @@ class AudioRendererImplTest : public ::testing::Test {
EXPECT_CALL(*decoder_, Stop(_))
.WillRepeatedly(Invoke(this, &AudioRendererImplTest::StopDecoder));
- // Set up audio properties.
- EXPECT_CALL(*decoder_, bits_per_channel())
- .WillRepeatedly(Return(audio_config.bits_per_channel()));
- EXPECT_CALL(*decoder_, channel_layout())
- .WillRepeatedly(Return(audio_config.channel_layout()));
- EXPECT_CALL(*decoder_, samples_per_second())
- .WillRepeatedly(Return(audio_config.samples_per_second()));
-
// Mock out demuxer reads
EXPECT_CALL(demuxer_stream_, Read(_)).WillRepeatedly(
RunCallback<0>(DemuxerStream::kOk, DecoderBuffer::CreateEOSBuffer()));
-
+ AudioParameters out_params =
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ kChannelLayout,
+ kSamplesPerSecond,
+ SampleFormatToBytesPerChannel(kSampleFormat) * 8,
+ 512);
+ hardware_config_.UpdateOutputConfig(out_params);
ScopedVector<AudioDecoder> decoders;
decoders.push_back(decoder_);
sink_ = new FakeAudioRendererSink();
@@ -92,7 +92,8 @@ class AudioRendererImplTest : public ::testing::Test {
message_loop_.message_loop_proxy(),
sink_,
decoders.Pass(),
- SetDecryptorReadyCB()));
+ SetDecryptorReadyCB(),
+ hardware_config_));
// Stub out time.
renderer_->set_now_cb_for_testing(base::Bind(
@@ -114,14 +115,14 @@ class AudioRendererImplTest : public ::testing::Test {
}
void ExpectUnsupportedAudioDecoderConfig() {
- EXPECT_CALL(*decoder_, bits_per_channel())
- .WillRepeatedly(Return(3));
- EXPECT_CALL(*decoder_, channel_layout())
- .WillRepeatedly(Return(CHANNEL_LAYOUT_UNSUPPORTED));
- EXPECT_CALL(*decoder_, samples_per_second())
- .WillRepeatedly(Return(0));
EXPECT_CALL(*decoder_, Initialize(_, _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
+ hardware_config_.UpdateOutputConfig(
+ AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ CHANNEL_LAYOUT_UNSUPPORTED,
+ 0,
+ 3,
+ 512));
}
MOCK_METHOD1(OnStatistics, void(const PipelineStatistics&));
@@ -138,8 +139,8 @@ class AudioRendererImplTest : public ::testing::Test {
.WillOnce(RunCallback<1>(PIPELINE_OK));
InitializeWithStatus(PIPELINE_OK);
- next_timestamp_.reset(
- new AudioTimestampHelper(decoder_->samples_per_second()));
+ next_timestamp_.reset(new AudioTimestampHelper(
+ hardware_config_.GetOutputConfig().sample_rate()));
}
void InitializeWithStatus(PipelineStatus expected) {
@@ -368,7 +369,7 @@ class AudioRendererImplTest : public ::testing::Test {
do {
TimeDelta audio_delay = TimeDelta::FromMicroseconds(
total_frames_read * Time::kMicrosecondsPerSecond /
- static_cast<float>(decoder_->samples_per_second()));
+ static_cast<float>(hardware_config_.GetOutputConfig().sample_rate()));
frames_read = renderer_->Render(
bus.get(), audio_delay.InMilliseconds());
@@ -460,6 +461,7 @@ class AudioRendererImplTest : public ::testing::Test {
base::MessageLoop message_loop_;
scoped_ptr<AudioRendererImpl> renderer_;
scoped_refptr<FakeAudioRendererSink> sink_;
+ AudioHardwareConfig hardware_config_;
// Whether or not the test needs the destructor to call Stop() on
// |renderer_| at destruction.

Powered by Google App Engine
This is Rietveld 408576698