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

Unified Diff: media/filters/ffmpeg_audio_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_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index b2578e5607e67151a78438fd1ee733ea0123ab1a..97c67f6a52a95e7c25a338d49d19f9963895fef2 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -45,8 +45,10 @@ static bool IsEndOfStream(int result, int decoded_size, Buffer* input) {
}
-FFmpegAudioDecoder::FFmpegAudioDecoder(MessageLoop* message_loop)
- : message_loop_(message_loop),
+FFmpegAudioDecoder::FFmpegAudioDecoder(
+ const base::Callback<MessageLoop*()>& message_loop_cb)
+ : message_loop_factory_cb_(message_loop_cb),
+ message_loop_(NULL),
codec_context_(NULL),
bits_per_channel_(0),
channel_layout_(CHANNEL_LAYOUT_NONE),
@@ -71,6 +73,14 @@ void FFmpegAudioDecoder::Initialize(
const scoped_refptr<DemuxerStream>& 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.";
+ }
message_loop_->PostTask(
FROM_HERE,
base::Bind(&FFmpegAudioDecoder::DoInitialize, this,

Powered by Google App Engine
This is Rietveld 408576698