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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 9632024: Create video and audio decoder threads on demand. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Log an error when Initialize is called more than once. Created 8 years, 9 months 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/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index f5eb500fa74d449c54f4fc417d553e7deb44ac37..0072b4c97a39c1b722533950f8aff819548b1061 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -51,8 +51,10 @@ static int GetThreadCount(CodecID codec_id) {
return decode_threads;
}
-FFmpegVideoDecoder::FFmpegVideoDecoder(MessageLoop* message_loop)
- : message_loop_(message_loop),
+FFmpegVideoDecoder::FFmpegVideoDecoder(
+ const base::Callback<MessageLoop*()>& message_loop_cb)
+ : message_loop_factory_cb_(message_loop_cb),
+ message_loop_(NULL),
state_(kUninitialized),
codec_context_(NULL),
av_frame_(NULL),
@@ -67,6 +69,15 @@ FFmpegVideoDecoder::~FFmpegVideoDecoder() {
void FFmpegVideoDecoder::Initialize(DemuxerStream* demuxer_stream,
const PipelineStatusCB& pipeline_status_cb,
const StatisticsCB& statistics_cb) {
+ if (!message_loop_) {
+ message_loop_ = message_loop_factory_cb_.Run();
+ message_loop_factory_cb_.Reset();
+ } else {
+ // TODO(scherkus): initialization currently happens more than once in
+ // PipelineIntegrationTest.BasicPlayback.
+ LOG(ERROR) << "Initialize has already been called.";
+ }
+
if (MessageLoop::current() != message_loop_) {
message_loop_->PostTask(FROM_HERE, base::Bind(
&FFmpegVideoDecoder::Initialize, this,

Powered by Google App Engine
This is Rietveld 408576698