summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-15 00:19:08 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-15 00:19:08 +0000
commitea7c48e5585defbff24d99348f11ccdaef6966ec (patch)
treeb87e09eff96603f4931a27037f0795ca86239389
parente4c0308111f092b0b99770c6b7bc25e8a8438fce (diff)
downloadchromium_src-ea7c48e5585defbff24d99348f11ccdaef6966ec.zip
chromium_src-ea7c48e5585defbff24d99348f11ccdaef6966ec.tar.gz
chromium_src-ea7c48e5585defbff24d99348f11ccdaef6966ec.tar.bz2
Make DecryptingDemuxerStream::Stop() synchronous.
BUG=349211 TEST=Current tests pass. Review URL: https://codereview.chromium.org/389413003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283101 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/filters/decoder_selector.cc5
-rw-r--r--media/filters/decoder_stream.cc39
-rw-r--r--media/filters/decoder_stream.h2
-rw-r--r--media/filters/decrypting_demuxer_stream.cc3
-rw-r--r--media/filters/decrypting_demuxer_stream.h2
-rw-r--r--media/filters/decrypting_demuxer_stream_unittest.cc2
6 files changed, 13 insertions, 40 deletions
diff --git a/media/filters/decoder_selector.cc b/media/filters/decoder_selector.cc
index 9020597..fbd6d01 100644
--- a/media/filters/decoder_selector.cc
+++ b/media/filters/decoder_selector.cc
@@ -136,9 +136,8 @@ void DecoderSelector<StreamType>::Abort() {
}
if (decrypted_stream_) {
- decrypted_stream_->Stop(
- base::Bind(&DecoderSelector<StreamType>::ReturnNullDecoder,
- weak_ptr_factory_.GetWeakPtr()));
+ decrypted_stream_->Stop();
+ ReturnNullDecoder();
return;
}
diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc
index 462ee36..8a17c59 100644
--- a/media/filters/decoder_stream.cc
+++ b/media/filters/decoder_stream.cc
@@ -166,9 +166,10 @@ void DecoderStream<StreamType>::Stop(const base::Closure& closure) {
DCHECK_NE(state_, STATE_STOPPED) << state_;
DCHECK(stop_cb_.is_null());
- stop_cb_ = closure;
-
+ // TODO(xhwang): This is the only asynchronousness in DecoderStream::Stop().
+ // Fix this so that we can merge the stopping code into the dtor.
if (state_ == STATE_INITIALIZING) {
+ stop_cb_ = closure;
decoder_selector_->Abort();
return;
}
@@ -186,23 +187,16 @@ void DecoderStream<StreamType>::Stop(const base::Closure& closure) {
if (!reset_cb_.is_null())
task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&reset_cb_));
- if (decrypting_demuxer_stream_) {
- decrypting_demuxer_stream_->Stop(base::Bind(
- &DecoderStream<StreamType>::StopDecoder, weak_factory_.GetWeakPtr()));
- return;
- }
-
- // We may not have a |decoder_| if Stop() was called during initialization.
- if (decoder_) {
- StopDecoder();
- return;
- }
+ if (decrypting_demuxer_stream_)
+ decrypting_demuxer_stream_->Stop();
+ if (decoder_)
+ decoder_->Stop();
state_ = STATE_STOPPED;
stream_ = NULL;
decoder_.reset();
decrypting_demuxer_stream_.reset();
- task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_));
+ task_runner_->PostTask(FROM_HERE, closure);
}
template <DemuxerStream::Type StreamType>
@@ -575,23 +569,6 @@ void DecoderStream<StreamType>::OnDecoderReset() {
ReinitializeDecoder();
}
-template <DemuxerStream::Type StreamType>
-void DecoderStream<StreamType>::StopDecoder() {
- FUNCTION_DVLOG(2);
- DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(state_ != STATE_UNINITIALIZED && state_ != STATE_STOPPED) << state_;
- DCHECK(!stop_cb_.is_null());
-
- state_ = STATE_STOPPED;
- decoder_->Stop();
- stream_ = NULL;
- decoder_.reset();
- decrypting_demuxer_stream_.reset();
- // Post |stop_cb_| because pending |read_cb_| and/or |reset_cb_| are also
- // posted in Stop().
- task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&stop_cb_));
-}
-
template class DecoderStream<DemuxerStream::VIDEO>;
template class DecoderStream<DemuxerStream::AUDIO>;
diff --git a/media/filters/decoder_stream.h b/media/filters/decoder_stream.h
index 7cb7873..32c1a28 100644
--- a/media/filters/decoder_stream.h
+++ b/media/filters/decoder_stream.h
@@ -165,8 +165,6 @@ class MEDIA_EXPORT DecoderStream {
void ResetDecoder();
void OnDecoderReset();
- void StopDecoder();
-
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
State state_;
diff --git a/media/filters/decrypting_demuxer_stream.cc b/media/filters/decrypting_demuxer_stream.cc
index 8493de6..e7b0f67 100644
--- a/media/filters/decrypting_demuxer_stream.cc
+++ b/media/filters/decrypting_demuxer_stream.cc
@@ -110,7 +110,7 @@ void DecryptingDemuxerStream::Reset(const base::Closure& closure) {
DoReset();
}
-void DecryptingDemuxerStream::Stop(const base::Closure& closure) {
+void DecryptingDemuxerStream::Stop() {
DVLOG(2) << __FUNCTION__ << " - state: " << state_;
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ != kUninitialized) << state_;
@@ -137,7 +137,6 @@ void DecryptingDemuxerStream::Stop(const base::Closure& closure) {
pending_buffer_to_decrypt_ = NULL;
state_ = kStopped;
- BindToCurrentLoop(closure).Run();
}
AudioDecoderConfig DecryptingDemuxerStream::audio_decoder_config() {
diff --git a/media/filters/decrypting_demuxer_stream.h b/media/filters/decrypting_demuxer_stream.h
index 6d308e5..b46ee3e 100644
--- a/media/filters/decrypting_demuxer_stream.h
+++ b/media/filters/decrypting_demuxer_stream.h
@@ -47,7 +47,7 @@ class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream {
// Note: During the teardown process, media pipeline will be waiting on the
// render main thread. If a Decryptor depends on the render main thread
// (e.g. PpapiDecryptor), the pending DecryptCB would not be satisfied.
- void Stop(const base::Closure& closure);
+ void Stop();
// DemuxerStream implementation.
virtual void Read(const ReadCB& read_cb) OVERRIDE;
diff --git a/media/filters/decrypting_demuxer_stream_unittest.cc b/media/filters/decrypting_demuxer_stream_unittest.cc
index 14485c0..27d1f33 100644
--- a/media/filters/decrypting_demuxer_stream_unittest.cc
+++ b/media/filters/decrypting_demuxer_stream_unittest.cc
@@ -242,7 +242,7 @@ class DecryptingDemuxerStreamTest : public testing::Test {
void Stop() {
if (is_decryptor_set_)
EXPECT_CALL(*decryptor_, CancelDecrypt(Decryptor::kAudio));
- demuxer_stream_->Stop(NewExpectedClosure());
+ demuxer_stream_->Stop();
message_loop_.RunUntilIdle();
}