summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 19:22:35 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 19:22:35 +0000
commit87ab8d1163b51008cc3e21d9b7b792c6d48dfa23 (patch)
tree85bad598c016639118b4bdc17c7714be71d8cd52 /media
parent40334320a21b19b7b261e59b987c054097386a1c (diff)
downloadchromium_src-87ab8d1163b51008cc3e21d9b7b792c6d48dfa23.zip
chromium_src-87ab8d1163b51008cc3e21d9b7b792c6d48dfa23.tar.gz
chromium_src-87ab8d1163b51008cc3e21d9b7b792c6d48dfa23.tar.bz2
Fixed Ended event when audio is disabled.
BUG=53539 TEST=unittests Review URL: http://codereview.chromium.org/3461003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/pipeline_impl.cc5
-rw-r--r--media/base/pipeline_impl.h3
-rw-r--r--media/base/pipeline_impl_unittest.cc13
3 files changed, 20 insertions, 1 deletions
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 75c522f..bd9e9fe 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -347,6 +347,7 @@ void PipelineImpl::ResetState() {
playback_rate_ = 0.0f;
error_ = PIPELINE_OK;
waiting_for_clock_update_ = false;
+ audio_disabled_ = false;
clock_.SetTime(kZero);
rendered_mime_types_.clear();
}
@@ -807,7 +808,7 @@ void PipelineImpl::NotifyEndedTask() {
DCHECK(audio_renderer || video_renderer);
// Make sure every extant renderer has ended.
- if ((audio_renderer && !audio_renderer->HasEnded()) ||
+ if ((audio_renderer && !audio_renderer->HasEnded() && !audio_disabled_) ||
(video_renderer && !video_renderer->HasEnded())) {
return;
}
@@ -834,6 +835,8 @@ void PipelineImpl::DisableAudioRendererTask() {
AutoLock auto_lock(lock_);
rendered_mime_types_.erase(mime_type::kMajorTypeAudio);
+ audio_disabled_ = true;
+
// Notify all filters of disabled audio renderer.
for (FilterVector::iterator iter = filters_.begin();
iter != filters_.end();
diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h
index 48db653..b7f4de3 100644
--- a/media/base/pipeline_impl.h
+++ b/media/base/pipeline_impl.h
@@ -404,6 +404,9 @@ class PipelineImpl : public Pipeline, public FilterHost {
// currently reading.
int64 current_bytes_;
+ // Set to true in DisableAudioRendererTask().
+ bool audio_disabled_;
+
// Keep track of the maximum buffered position so the buffering appears
// smooth.
// TODO(vrk): This is a hack.
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index 181f07d..36869e9 100644
--- a/media/base/pipeline_impl_unittest.cc
+++ b/media/base/pipeline_impl_unittest.cc
@@ -551,6 +551,10 @@ TEST_F(PipelineImplTest, DisableAudioRenderer) {
streams.push_back(audio_stream());
streams.push_back(video_stream());
+ pipeline_->SetPipelineEndedCallback(
+ NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_),
+ &CallbackHelper::OnEnded));
+
InitializeDataSource();
InitializeDemuxer(&streams, base::TimeDelta());
InitializeAudioDecoder(audio_stream());
@@ -580,6 +584,15 @@ TEST_F(PipelineImplTest, DisableAudioRenderer) {
OnAudioRendererDisabled());
mocks_->audio_renderer()->SetPlaybackRate(1.0f);
+
+ // Verify that ended event is fired when video ends.
+ EXPECT_CALL(*mocks_->audio_renderer(), HasEnded())
+ .WillOnce(Return(false));
+ EXPECT_CALL(*mocks_->video_renderer(), HasEnded())
+ .WillOnce(Return(true));
+ EXPECT_CALL(callbacks_, OnEnded());
+ FilterHost* host = pipeline_;
+ host->NotifyEnded();
}
TEST_F(PipelineImplTest, EndedCallback) {