Index: content/renderer/media/rtc_video_decoder.cc |
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc |
index 3e912d79980222d47e75f94adaa854a420962618..acec934b15a9a63f3abf74e7b1a9da4efba69245 100644 |
--- a/content/renderer/media/rtc_video_decoder.cc |
+++ b/content/renderer/media/rtc_video_decoder.cc |
@@ -11,6 +11,7 @@ |
#include "base/metrics/histogram.h" |
#include "base/safe_numerics.h" |
#include "base/stl_util.h" |
+#include "base/synchronization/waitable_event.h" |
#include "base/task_runner_util.h" |
#include "content/child/child_thread.h" |
#include "content/renderer/media/native_handle_impl.h" |
@@ -83,18 +84,7 @@ RTCVideoDecoder::RTCVideoDecoder( |
decode_complete_callback_(NULL), |
num_shm_buffers_(0), |
next_bitstream_buffer_id_(0), |
- reset_bitstream_buffer_id_(ID_INVALID) { |
- DCHECK(!vda_loop_proxy_->BelongsToCurrentThread()); |
- base::WaitableEvent message_loop_async_waiter(false, false); |
- // Waiting here is safe. The media thread is stopped in the child thread and |
- // the child thread is blocked when VideoDecoderFactory::CreateVideoDecoder |
- // runs. |
- vda_loop_proxy_->PostTask(FROM_HERE, |
- base::Bind(&RTCVideoDecoder::Initialize, |
- base::Unretained(this), |
- &message_loop_async_waiter)); |
- message_loop_async_waiter.Wait(); |
-} |
+ reset_bitstream_buffer_id_(ID_INVALID) {} |
RTCVideoDecoder::~RTCVideoDecoder() { |
DVLOG(2) << "~RTCVideoDecoder"; |
@@ -134,9 +124,15 @@ scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create( |
return decoder.Pass(); |
} |
+ base::WaitableEvent waiter(true, false); |
decoder.reset(new RTCVideoDecoder(factories)); |
- decoder->vda_ = |
- factories->CreateVideoDecodeAccelerator(profile, decoder.get()).Pass(); |
+ decoder->vda_loop_proxy_->PostTask(FROM_HERE, |
+ base::Bind(&RTCVideoDecoder::CreateVDA, |
+ base::Unretained(decoder.get()), |
+ profile, |
+ &decoder->vda_, |
+ &waiter)); |
+ waiter.Wait(); |
// vda can be NULL if VP8 is not supported. |
if (decoder->vda_ != NULL) { |
decoder->state_ = INITIALIZED; |
@@ -466,21 +462,6 @@ void RTCVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { |
state_ = DECODE_ERROR; |
} |
-void RTCVideoDecoder::WillDestroyCurrentMessageLoop() { |
- DVLOG(2) << "WillDestroyCurrentMessageLoop"; |
- DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
- factories_->Abort(); |
- weak_factory_.InvalidateWeakPtrs(); |
- DestroyVDA(); |
-} |
- |
-void RTCVideoDecoder::Initialize(base::WaitableEvent* waiter) { |
- DVLOG(2) << "Initialize"; |
- DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
- base::MessageLoop::current()->AddDestructionObserver(this); |
- waiter->Signal(); |
-} |
- |
void RTCVideoDecoder::RequestBufferDecode() { |
DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
if (!vda_) |
@@ -640,6 +621,14 @@ void RTCVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id, |
vda_->ReusePictureBuffer(picture_buffer_id); |
} |
+void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile, |
+ scoped_ptr<media::VideoDecodeAccelerator>* vda, |
+ base::WaitableEvent* waiter) { |
+ DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
+ *vda = factories_->CreateVideoDecodeAccelerator(profile, this); |
wuchengli
2013/10/16 07:43:17
Just use |vda_| here and remove the parameter?
sheu
2013/10/21 05:17:35
Done.
|
+ waiter->Signal(); |
+} |
+ |
void RTCVideoDecoder::DestroyTextures() { |
DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
std::map<int32, media::PictureBuffer>::iterator it; |