summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 01:11:36 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 01:11:36 +0000
commitd553f93de393e1d1b21a622bab3cfcf1c8cd0dfe (patch)
treecf83c380f383acdd13dcd92f8e62e216e638cbaa /media
parent63386243d93074951d106c0513185458d96cf4a6 (diff)
downloadchromium_src-d553f93de393e1d1b21a622bab3cfcf1c8cd0dfe.zip
chromium_src-d553f93de393e1d1b21a622bab3cfcf1c8cd0dfe.tar.gz
chromium_src-d553f93de393e1d1b21a622bab3cfcf1c8cd0dfe.tar.bz2
Moving underflow callback execution so ResumeAfterUnderflow() can be called inside the callback.
BUG=103920 TEST=AudioRendererBaseTest.Underflow_ResumeFromCallback Review URL: http://codereview.chromium.org/9005022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/audio_renderer_base.cc6
-rw-r--r--media/filters/audio_renderer_base_unittest.cc33
2 files changed, 38 insertions, 1 deletions
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc
index e3f2164..bca260a 100644
--- a/media/filters/audio_renderer_base.cc
+++ b/media/filters/audio_renderer_base.cc
@@ -195,6 +195,7 @@ uint32 AudioRendererBase::FillBuffer(uint8* dest,
// FillBuffer().
base::TimeDelta last_fill_buffer_time;
size_t dest_written = 0;
+ base::Closure underflow_cb;
{
base::AutoLock auto_lock(lock_);
@@ -237,7 +238,7 @@ uint32 AudioRendererBase::FillBuffer(uint8* dest,
}
} else if (state_ == kPlaying && !recieved_end_of_stream_) {
state_ = kUnderflow;
- underflow_callback_.Run();
+ underflow_cb = underflow_callback_;
}
} else {
// Otherwise fill the buffer.
@@ -262,6 +263,9 @@ uint32 AudioRendererBase::FillBuffer(uint8* dest,
host()->SetTime(last_fill_buffer_time);
}
+ if (!underflow_cb.is_null())
+ underflow_cb.Run();
+
return dest_written;
}
diff --git a/media/filters/audio_renderer_base_unittest.cc b/media/filters/audio_renderer_base_unittest.cc
index 964686e..2dd5cc8 100644
--- a/media/filters/audio_renderer_base_unittest.cc
+++ b/media/filters/audio_renderer_base_unittest.cc
@@ -172,6 +172,10 @@ class AudioRendererBaseTest : public ::testing::Test {
return buffer_capacity() - bytes_buffered();
}
+ void CallResumeAfterUnderflow() {
+ renderer_->ResumeAfterUnderflow(false);
+ }
+
// Fixture members.
scoped_refptr<MockAudioRendererBase> renderer_;
scoped_refptr<MockAudioDecoder> decoder_;
@@ -321,4 +325,33 @@ TEST_F(AudioRendererBaseTest, Underflow_EndOfStream) {
EXPECT_FALSE(muted);
}
+TEST_F(AudioRendererBaseTest, Underflow_ResumeFromCallback) {
+ Initialize();
+ Preroll();
+ Play();
+
+ // Drain internal buffer, we should have a pending read.
+ EXPECT_CALL(*decoder_, Read(_));
+ EXPECT_TRUE(ConsumeBufferedData(bytes_buffered(), NULL));
+
+ // Verify the next FillBuffer() call triggers the underflow callback
+ // since the decoder hasn't delivered any data after it was drained.
+ const size_t kDataSize = 1024;
+ EXPECT_CALL(*this, OnUnderflow())
+ .WillOnce(Invoke(this, &AudioRendererBaseTest::CallResumeAfterUnderflow));
+ EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
+
+ // Verify after resuming that we're still not getting data.
+ bool muted = false;
+ EXPECT_EQ(0u, bytes_buffered());
+ EXPECT_TRUE(ConsumeBufferedData(kDataSize, &muted));
+ EXPECT_TRUE(muted);
+
+ // Deliver data, we should get non-muted audio.
+ DeliverRemainingAudio();
+ EXPECT_CALL(*decoder_, Read(_));
+ EXPECT_TRUE(ConsumeBufferedData(kDataSize, &muted));
+ EXPECT_FALSE(muted);
+}
+
} // namespace media