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

Unified Diff: media/filters/video_renderer_base.cc

Issue 11428095: Pass in media message loop to VideoRendererBase and enforce calling on the right thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/video_renderer_base.cc
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 8f6bf8a3d0254dc82578f0fb4a5f7b20f1a7f029..07c0141bf71c740076237e34d953d62d85ffd01b 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
+#include "base/message_loop.h"
#include "base/threading/platform_thread.h"
#include "media/base/buffers.h"
#include "media/base/limits.h"
@@ -19,9 +20,11 @@ base::TimeDelta VideoRendererBase::kMaxLastFrameDuration() {
return base::TimeDelta::FromMilliseconds(250);
}
-VideoRendererBase::VideoRendererBase(const base::Closure& paint_cb,
- const SetOpaqueCB& set_opaque_cb,
- bool drop_frames)
+VideoRendererBase::VideoRendererBase(
+ const base::Closure& paint_cb,
+ const SetOpaqueCB& set_opaque_cb,
+ bool drop_frames,
+ const scoped_refptr<base::MessageLoopProxy>& message_loop)
: frame_available_(&lock_),
state_(kUninitialized),
thread_(base::kNullThreadHandle),
@@ -31,7 +34,8 @@ VideoRendererBase::VideoRendererBase(const base::Closure& paint_cb,
drop_frames_(drop_frames),
playback_rate_(0),
paint_cb_(paint_cb),
- set_opaque_cb_(set_opaque_cb) {
+ set_opaque_cb_(set_opaque_cb),
+ decoder_message_loop_(message_loop) {
Ami GONE FROM CHROMIUM 2012/11/29 23:34:23 Could DCHECK that this is *not* the current loop,
DCHECK(!paint_cb_.is_null());
}
@@ -55,11 +59,9 @@ void VideoRendererBase::Flush(const base::Closure& callback) {
flush_cb_ = callback;
state_ = kFlushingDecoder;
- // We must unlock here because the callback might run within the Flush()
- // call.
- // TODO: Remove this line when fixing http://crbug.com/125020
- base::AutoUnlock auto_unlock(lock_);
- decoder_->Reset(base::Bind(&VideoRendererBase::OnDecoderFlushDone, this));
+ decoder_message_loop_->PostTask(FROM_HERE, base::Bind(
+ &VideoDecoder::Reset, decoder_, base::Bind(
+ &VideoRendererBase::OnDecoderFlushDone, this)));
}
void VideoRendererBase::Stop(const base::Closure& callback) {
@@ -90,7 +92,8 @@ void VideoRendererBase::Stop(const base::Closure& callback) {
if (thread_to_join != base::kNullThreadHandle)
base::PlatformThread::Join(thread_to_join);
- decoder_->Stop(callback);
+ decoder_message_loop_->PostTask(FROM_HERE, base::Bind(
+ &VideoDecoder::Stop, decoder_, callback));
}
void VideoRendererBase::SetPlaybackRate(float playback_rate) {
@@ -195,6 +198,7 @@ void VideoRendererBase::OnDecoderInitDone(
// have not populated any buffers yet.
state_ = kFlushed;
+ // XXX we're taking advantage of the fact this is already on the right thread
set_opaque_cb_.Run(!decoder_->HasAlpha());
set_opaque_cb_.Reset();
@@ -571,7 +575,9 @@ void VideoRendererBase::AttemptRead_Locked() {
}
pending_read_ = true;
- decoder_->Read(base::Bind(&VideoRendererBase::FrameReady, this));
+ decoder_message_loop_->PostTask(FROM_HERE, base::Bind(
+ &VideoDecoder::Read, decoder_, base::Bind(
+ &VideoRendererBase::FrameReady, this)));
}
void VideoRendererBase::OnDecoderFlushDone() {

Powered by Google App Engine
This is Rietveld 408576698