Index: media/cast/video_receiver/codecs/vp8/vp8_decoder.cc |
diff --git a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc |
index bf56b0a2ad11896d851fd498b95e18de54fe8883..ecb7e63249b58d876cc47dd5976af51f2b464793 100644 |
--- a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc |
+++ b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc |
@@ -19,18 +19,20 @@ void LogFrameDecodedEvent(CastEnvironment* const cast_environment, |
// 0, frame_id); |
} |
-Vp8Decoder::Vp8Decoder(int number_of_cores, |
- scoped_refptr<CastEnvironment> cast_environment) |
+Vp8Decoder::Vp8Decoder(scoped_refptr<CastEnvironment> cast_environment) |
: decoder_(new vpx_dec_ctx_t()), |
cast_environment_(cast_environment) { |
- InitDecode(number_of_cores); |
+ // Make sure that we initialize the decoder from the correct thread. |
+ cast_environment_->PostTask(CastEnvironment::VIDEO_DECODER, FROM_HERE, |
+ base::Bind(&Vp8Decoder::InitDecoder, base::Unretained(this))); |
} |
Vp8Decoder::~Vp8Decoder() {} |
-void Vp8Decoder::InitDecode(int number_of_cores) { |
- vpx_codec_dec_cfg_t cfg; |
- cfg.threads = number_of_cores; |
+void Vp8Decoder::InitDecoder() { |
+ vpx_codec_dec_cfg_t cfg; |
+ // Initializing to use one core. |
+ cfg.threads = 1; |
vpx_codec_flags_t flags = VPX_CODEC_USE_POSTPROC; |
if (vpx_codec_dec_init(decoder_.get(), vpx_codec_vp8_dx(), &cfg, flags)) { |
@@ -41,6 +43,7 @@ void Vp8Decoder::InitDecode(int number_of_cores) { |
bool Vp8Decoder::Decode(const EncodedVideoFrame* encoded_frame, |
const base::TimeTicks render_time, |
const VideoFrameDecodedCallback& frame_decoded_cb) { |
+ DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO_DECODER)); |
const int frame_id_int = static_cast<int>(encoded_frame->frame_id); |
VLOG(1) << "VP8 decode frame:" << frame_id_int |
<< " sized:" << encoded_frame->data.size(); |
@@ -94,8 +97,8 @@ bool Vp8Decoder::Decode(const EncodedVideoFrame* encoded_frame, |
// Log:: Decoding complete (should be called from the main thread). |
cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, base::Bind( |
LogFrameDecodedEvent, cast_environment_,encoded_frame->frame_id)); |
- VLOG(1) << "Decoded frame " << frame_id_int; |
+ VLOG(1) << "Decoded frame " << frame_id_int; |
// Frame decoded - return frame to the user via callback. |
cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
base::Bind(frame_decoded_cb, base::Passed(&decoded_frame), |