Chromium Code Reviews| 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 c84ccbafcdc69265e651733bb8c45b715db77b52..0f58c7afd0f04866a0da6ed8ef9b5a916a5fdc26 100644 |
| --- a/media/filters/audio_renderer_impl_unittest.cc |
| +++ b/media/filters/audio_renderer_impl_unittest.cc |
| @@ -64,8 +64,8 @@ class AudioRendererImplTest : public ::testing::Test { |
| demuxer_stream_.set_audio_decoder_config(audio_config); |
| // Used to save callbacks and run them at a later time. |
| - EXPECT_CALL(*decoder_, Read(_)) |
| - .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ReadDecoder)); |
| + EXPECT_CALL(*decoder_, Decode(_, _)) |
| + .WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder)); |
| EXPECT_CALL(*decoder_, Reset(_)) |
| .WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder)); |
| @@ -81,6 +81,10 @@ class AudioRendererImplTest : public ::testing::Test { |
| 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())); |
| + |
| ScopedVector<AudioDecoder> decoders; |
| decoders.push_back(decoder_); |
| sink_ = new FakeAudioRendererSink(); |
| @@ -105,7 +109,7 @@ class AudioRendererImplTest : public ::testing::Test { |
| } |
| void ExpectUnsupportedAudioDecoder() { |
| - EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| + EXPECT_CALL(*decoder_, Initialize(_, _)) |
| .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); |
| } |
| @@ -116,7 +120,7 @@ class AudioRendererImplTest : public ::testing::Test { |
| .WillRepeatedly(Return(CHANNEL_LAYOUT_UNSUPPORTED)); |
| EXPECT_CALL(*decoder_, samples_per_second()) |
| .WillRepeatedly(Return(0)); |
| - EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| + EXPECT_CALL(*decoder_, Initialize(_, _)) |
| .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| } |
| @@ -130,7 +134,7 @@ class AudioRendererImplTest : public ::testing::Test { |
| } |
| void Initialize() { |
| - EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| + EXPECT_CALL(*decoder_, Initialize(_, _)) |
| .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| InitializeWithStatus(PIPELINE_OK); |
| @@ -159,11 +163,11 @@ class AudioRendererImplTest : public ::testing::Test { |
| event.RunAndWaitForStatus(expected); |
| // We should have no reads. |
| - EXPECT_TRUE(read_cb_.is_null()); |
| + EXPECT_TRUE(decode_cb_.is_null()); |
| } |
| void InitializeAndStop() { |
| - EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| + EXPECT_CALL(*decoder_, Initialize(_, _)) |
| .WillOnce(RunCallback<1>(PIPELINE_OK)); |
| WaitableMessageLoopEvent event; |
| renderer_->Initialize( |
| @@ -189,7 +193,7 @@ class AudioRendererImplTest : public ::testing::Test { |
| } |
| void InitializeAndStopDuringDecoderInit() { |
| - EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| + EXPECT_CALL(*decoder_, Initialize(_, _)) |
| .WillOnce(EnterPendingDecoderInitStateAction(this)); |
| WaitableMessageLoopEvent event; |
| renderer_->Initialize( |
| @@ -242,12 +246,12 @@ class AudioRendererImplTest : public ::testing::Test { |
| // Fill entire buffer to complete prerolling. |
| WaitableMessageLoopEvent event; |
| renderer_->Preroll(timestamp, event.GetPipelineStatusCB()); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| DeliverRemainingAudio(); |
| event.RunAndWaitForStatus(PIPELINE_OK); |
| // We should have no reads. |
|
xhwang
2014/03/05 00:40:46
s/read/decode
rileya (GONE FROM CHROMIUM)
2014/03/05 08:08:28
To this and the other comments in this file, I thi
xhwang
2014/03/06 16:41:13
I see. "read" sgtm. You can do the cleanup later.
|
| - EXPECT_TRUE(read_cb_.is_null()); |
| + EXPECT_TRUE(decode_cb_.is_null()); |
| } |
| void Play() { |
| @@ -278,28 +282,28 @@ class AudioRendererImplTest : public ::testing::Test { |
| } |
| bool IsReadPending() const { |
|
xhwang
2014/03/05 00:40:46
s/Read/Decode
|
| - return !read_cb_.is_null(); |
| + return !decode_cb_.is_null(); |
| } |
| - void WaitForPendingRead() { |
| - SCOPED_TRACE("WaitForPendingRead()"); |
| - if (!read_cb_.is_null()) |
| + void WaitForPendingDecode() { |
| + SCOPED_TRACE("WaitForPendingDecode()"); |
| + if (!decode_cb_.is_null()) |
| return; |
| - DCHECK(wait_for_pending_read_cb_.is_null()); |
| + DCHECK(wait_for_pending_decode_cb_.is_null()); |
| WaitableMessageLoopEvent event; |
| - wait_for_pending_read_cb_ = event.GetClosure(); |
| + wait_for_pending_decode_cb_ = event.GetClosure(); |
| event.RunAndWait(); |
| - DCHECK(!read_cb_.is_null()); |
| - DCHECK(wait_for_pending_read_cb_.is_null()); |
| + DCHECK(!decode_cb_.is_null()); |
| + DCHECK(wait_for_pending_decode_cb_.is_null()); |
| } |
| // Delivers |size| frames with value kPlayingAudio to |renderer_|. |
| void SatisfyPendingRead(int size) { |
| CHECK_GT(size, 0); |
| - CHECK(!read_cb_.is_null()); |
| + CHECK(!decode_cb_.is_null()); |
| scoped_refptr<AudioBuffer> buffer = |
| MakePlanarAudioBuffer<float>(kSampleFormat, |
| @@ -409,7 +413,7 @@ class AudioRendererImplTest : public ::testing::Test { |
| // Drain internal buffer, we should have a pending read. |
| int total_frames = frames_buffered(); |
| int frames_filled = ConsumeAllBufferedData(); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Due to how the cross-fade algorithm works we won't get an exact match |
| // between the ideal and expected number of frames consumed. In the faster |
| @@ -466,28 +470,29 @@ class AudioRendererImplTest : public ::testing::Test { |
| return time_; |
| } |
| - void ReadDecoder(const AudioDecoder::ReadCB& read_cb) { |
| + void DecodeDecoder(const scoped_refptr<DecoderBuffer>& buffer, |
| + const AudioDecoder::DecodeCB& decode_cb) { |
| // We shouldn't ever call Read() after Stop(): |
| EXPECT_TRUE(stop_decoder_cb_.is_null()); |
| // TODO(scherkus): Make this a DCHECK after threading semantics are fixed. |
| if (base::MessageLoop::current() != &message_loop_) { |
| message_loop_.PostTask(FROM_HERE, base::Bind( |
| - &AudioRendererImplTest::ReadDecoder, |
| - base::Unretained(this), read_cb)); |
| + &AudioRendererImplTest::DecodeDecoder, |
| + base::Unretained(this), buffer, decode_cb)); |
| return; |
| } |
| - CHECK(read_cb_.is_null()) << "Overlapping reads are not permitted"; |
| - read_cb_ = read_cb; |
| + CHECK(decode_cb_.is_null()) << "Overlapping decodes are not permitted"; |
| + decode_cb_ = decode_cb; |
| - // Wake up WaitForPendingRead() if needed. |
| - if (!wait_for_pending_read_cb_.is_null()) |
| - base::ResetAndReturn(&wait_for_pending_read_cb_).Run(); |
| + // Wake up WaitForPendingDecode() if needed. |
| + if (!wait_for_pending_decode_cb_.is_null()) |
| + base::ResetAndReturn(&wait_for_pending_decode_cb_).Run(); |
| } |
| void ResetDecoder(const base::Closure& reset_cb) { |
| - CHECK(read_cb_.is_null()) |
| + CHECK(decode_cb_.is_null()) |
| << "Reset overlapping with reads is not permitted"; |
| message_loop_.PostTask(FROM_HERE, reset_cb); |
| @@ -503,8 +508,8 @@ class AudioRendererImplTest : public ::testing::Test { |
| void DeliverBuffer(AudioDecoder::Status status, |
| const scoped_refptr<AudioBuffer>& buffer) { |
| - CHECK(!read_cb_.is_null()); |
| - base::ResetAndReturn(&read_cb_).Run(status, buffer); |
| + CHECK(!decode_cb_.is_null()); |
| + base::ResetAndReturn(&decode_cb_).Run(status, buffer); |
| } |
| MockDemuxerStream demuxer_stream_; |
| @@ -515,13 +520,13 @@ class AudioRendererImplTest : public ::testing::Test { |
| TimeTicks time_; |
| // Used for satisfying reads. |
|
xhwang
2014/03/05 00:40:46
ditto
|
| - AudioDecoder::ReadCB read_cb_; |
| + AudioDecoder::DecodeCB decode_cb_; |
| scoped_ptr<AudioTimestampHelper> next_timestamp_; |
| WaitableMessageLoopEvent ended_event_; |
| - // Run during ReadDecoder() to unblock WaitForPendingRead(). |
| - base::Closure wait_for_pending_read_cb_; |
| + // Run during DecodeDecoder() to unblock WaitForPendingDecode(). |
| + base::Closure wait_for_pending_decode_cb_; |
| base::Closure stop_decoder_cb_; |
| PipelineStatusCB init_decoder_cb_; |
| @@ -555,7 +560,7 @@ TEST_F(AudioRendererImplTest, Play) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| } |
| TEST_F(AudioRendererImplTest, EndOfStream) { |
| @@ -580,7 +585,7 @@ TEST_F(AudioRendererImplTest, Underflow) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Verify the next FillBuffer() call triggers the underflow callback |
| // since the decoder hasn't delivered any data after it was drained. |
| @@ -614,7 +619,7 @@ TEST_F(AudioRendererImplTest, Underflow_FollowedByFlush) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Verify the next FillBuffer() call triggers the underflow callback |
| // since the decoder hasn't delivered any data after it was drained. |
| @@ -648,7 +653,7 @@ TEST_F(AudioRendererImplTest, Underflow_EndOfStream) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Verify the next FillBuffer() call triggers the underflow callback |
| // since the decoder hasn't delivered any data after it was drained. |
| @@ -657,7 +662,7 @@ TEST_F(AudioRendererImplTest, Underflow_EndOfStream) { |
| // Deliver a little bit of data. |
| SatisfyPendingRead(kDataSize); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Verify we're getting muted audio during underflow. |
| bool muted = false; |
| @@ -685,7 +690,7 @@ TEST_F(AudioRendererImplTest, Underflow_ResumeFromCallback) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Verify the next FillBuffer() call triggers the underflow callback |
| // since the decoder hasn't delivered any data after it was drained. |
| @@ -712,7 +717,7 @@ TEST_F(AudioRendererImplTest, Underflow_SetPlaybackRate) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state()); |
| @@ -748,7 +753,7 @@ TEST_F(AudioRendererImplTest, Underflow_PausePlay) { |
| // Drain internal buffer, we should have a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state()); |
| @@ -778,7 +783,7 @@ TEST_F(AudioRendererImplTest, AbortPendingRead_Preroll) { |
| // Start prerolling and wait for a read. |
| WaitableMessageLoopEvent event; |
| renderer_->Preroll(TimeDelta(), event.GetPipelineStatusCB()); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Simulate the decoder aborting the pending read. |
| AbortPendingRead(); |
| @@ -798,7 +803,7 @@ TEST_F(AudioRendererImplTest, AbortPendingRead_Pause) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Start pausing. |
| WaitableMessageLoopEvent event; |
| @@ -823,7 +828,7 @@ TEST_F(AudioRendererImplTest, AbortPendingRead_Flush) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| Pause(); |
| @@ -851,7 +856,7 @@ TEST_F(AudioRendererImplTest, PendingRead_Pause) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| // Start pausing. |
| WaitableMessageLoopEvent event; |
| @@ -875,7 +880,7 @@ TEST_F(AudioRendererImplTest, PendingRead_Flush) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| Pause(); |
| @@ -903,7 +908,7 @@ TEST_F(AudioRendererImplTest, PendingRead_Stop) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| Pause(); |
| @@ -928,7 +933,7 @@ TEST_F(AudioRendererImplTest, PendingFlush_Stop) { |
| // Partially drain internal buffer so we get a pending read. |
| EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL)); |
| - WaitForPendingRead(); |
| + WaitForPendingDecode(); |
| Pause(); |