| 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 f85439a7f0a2b1621e3e12e3862916d0569361bc..83fa58006965465abe8cca4c6bb6a3a9d6cae59d 100644
|
| --- a/content/renderer/media/rtc_video_decoder.cc
|
| +++ b/content/renderer/media/rtc_video_decoder.cc
|
| @@ -76,7 +76,7 @@ RTCVideoDecoder::RTCVideoDecoder(
|
| : weak_factory_(this),
|
| weak_this_(weak_factory_.GetWeakPtr()),
|
| factories_(factories),
|
| - vda_loop_proxy_(factories->GetMessageLoop()),
|
| + vda_task_runner_(factories->GetTaskRunner()),
|
| decoder_texture_target_(0),
|
| next_picture_buffer_id_(0),
|
| state_(UNINITIALIZED),
|
| @@ -84,22 +84,22 @@ RTCVideoDecoder::RTCVideoDecoder(
|
| num_shm_buffers_(0),
|
| next_bitstream_buffer_id_(0),
|
| reset_bitstream_buffer_id_(ID_INVALID) {
|
| - DCHECK(!vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(!vda_task_runner_->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));
|
| + vda_task_runner_->PostTask(FROM_HERE,
|
| + base::Bind(&RTCVideoDecoder::Initialize,
|
| + base::Unretained(this),
|
| + &message_loop_async_waiter));
|
| message_loop_async_waiter.Wait();
|
| }
|
|
|
| RTCVideoDecoder::~RTCVideoDecoder() {
|
| DVLOG(2) << "~RTCVideoDecoder";
|
| // Destroy VDA and remove |this| from the observer if this is vda thread.
|
| - if (vda_loop_proxy_->BelongsToCurrentThread()) {
|
| + if (vda_task_runner_->BelongsToCurrentThread()) {
|
| base::MessageLoop::current()->RemoveDestructionObserver(this);
|
| DestroyVDA();
|
| } else {
|
| @@ -145,7 +145,7 @@ scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create(
|
| if (decoder->vda_ != NULL) {
|
| decoder->state_ = INITIALIZED;
|
| } else {
|
| - factories->GetMessageLoop()->DeleteSoon(FROM_HERE, decoder.release());
|
| + factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder.release());
|
| }
|
| return decoder.Pass();
|
| }
|
| @@ -166,11 +166,11 @@ int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings,
|
| }
|
| // Create some shared memory if the queue is empty.
|
| if (available_shm_segments_.size() == 0) {
|
| - vda_loop_proxy_->PostTask(FROM_HERE,
|
| - base::Bind(&RTCVideoDecoder::CreateSHM,
|
| - weak_this_,
|
| - kMaxInFlightDecodes,
|
| - kSharedMemorySegmentBytes));
|
| + vda_task_runner_->PostTask(FROM_HERE,
|
| + base::Bind(&RTCVideoDecoder::CreateSHM,
|
| + weak_this_,
|
| + kMaxInFlightDecodes,
|
| + kSharedMemorySegmentBytes));
|
| }
|
| return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_OK);
|
| }
|
| @@ -256,7 +256,7 @@ int32_t RTCVideoDecoder::Decode(
|
| }
|
|
|
| SaveToDecodeBuffers_Locked(inputImage, shm_buffer.Pass(), buffer_data);
|
| - vda_loop_proxy_->PostTask(
|
| + vda_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&RTCVideoDecoder::RequestBufferDecode, weak_this_));
|
| return WEBRTC_VIDEO_CODEC_OK;
|
| }
|
| @@ -290,7 +290,7 @@ int32_t RTCVideoDecoder::Reset() {
|
| // If VDA is already resetting, no need to request the reset again.
|
| if (state_ != RESETTING) {
|
| state_ = RESETTING;
|
| - vda_loop_proxy_->PostTask(
|
| + vda_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&RTCVideoDecoder::ResetInternal, weak_this_));
|
| }
|
| return WEBRTC_VIDEO_CODEC_OK;
|
| @@ -304,7 +304,7 @@ void RTCVideoDecoder::NotifyInitializeDone() {
|
| void RTCVideoDecoder::ProvidePictureBuffers(uint32 count,
|
| const gfx::Size& size,
|
| uint32 texture_target) {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target;
|
|
|
| if (!vda_)
|
| @@ -339,7 +339,7 @@ void RTCVideoDecoder::ProvidePictureBuffers(uint32 count,
|
|
|
| void RTCVideoDecoder::DismissPictureBuffer(int32 id) {
|
| DVLOG(3) << "DismissPictureBuffer. id=" << id;
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
|
|
| std::map<int32, media::PictureBuffer>::iterator it =
|
| assigned_picture_buffers_.find(id);
|
| @@ -367,7 +367,7 @@ void RTCVideoDecoder::DismissPictureBuffer(int32 id) {
|
|
|
| void RTCVideoDecoder::PictureReady(const media::Picture& picture) {
|
| DVLOG(3) << "PictureReady";
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
|
|
| std::map<int32, media::PictureBuffer>::iterator it =
|
| assigned_picture_buffers_.find(picture.picture_buffer_id());
|
| @@ -440,7 +440,7 @@ scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame(
|
|
|
| void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) {
|
| DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id;
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
|
|
| std::map<int32, SHMBuffer*>::iterator it =
|
| bitstream_buffers_in_decoder_.find(id);
|
| @@ -465,7 +465,7 @@ void RTCVideoDecoder::NotifyFlushDone() {
|
| }
|
|
|
| void RTCVideoDecoder::NotifyResetDone() {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| DVLOG(3) << "NotifyResetDone";
|
|
|
| if (!vda_)
|
| @@ -481,7 +481,7 @@ void RTCVideoDecoder::NotifyResetDone() {
|
| }
|
|
|
| void RTCVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| if (!vda_)
|
| return;
|
|
|
| @@ -497,7 +497,7 @@ void RTCVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) {
|
|
|
| void RTCVideoDecoder::WillDestroyCurrentMessageLoop() {
|
| DVLOG(2) << "WillDestroyCurrentMessageLoop";
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| factories_->Abort();
|
| weak_factory_.InvalidateWeakPtrs();
|
| DestroyVDA();
|
| @@ -505,13 +505,13 @@ void RTCVideoDecoder::WillDestroyCurrentMessageLoop() {
|
|
|
| void RTCVideoDecoder::Initialize(base::WaitableEvent* waiter) {
|
| DVLOG(2) << "Initialize";
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| base::MessageLoop::current()->AddDestructionObserver(this);
|
| waiter->Signal();
|
| }
|
|
|
| void RTCVideoDecoder::RequestBufferDecode() {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| if (!vda_)
|
| return;
|
|
|
| @@ -633,7 +633,7 @@ void RTCVideoDecoder::MovePendingBuffersToDecodeBuffers() {
|
| }
|
|
|
| void RTCVideoDecoder::ResetInternal() {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| DVLOG(2) << "ResetInternal";
|
| if (vda_)
|
| vda_->Reset();
|
| @@ -641,7 +641,7 @@ void RTCVideoDecoder::ResetInternal() {
|
|
|
| void RTCVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id,
|
| uint32 sync_point) {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| DVLOG(3) << "ReusePictureBuffer. id=" << picture_buffer_id;
|
|
|
| if (!vda_)
|
| @@ -670,7 +670,7 @@ void RTCVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id,
|
| }
|
|
|
| void RTCVideoDecoder::DestroyTextures() {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| std::map<int32, media::PictureBuffer>::iterator it;
|
|
|
| for (it = assigned_picture_buffers_.begin();
|
| @@ -690,7 +690,7 @@ void RTCVideoDecoder::DestroyTextures() {
|
|
|
| void RTCVideoDecoder::DestroyVDA() {
|
| DVLOG(2) << "DestroyVDA";
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| if (vda_)
|
| vda_.release()->Destroy();
|
| DestroyTextures();
|
| @@ -711,7 +711,7 @@ scoped_ptr<RTCVideoDecoder::SHMBuffer> RTCVideoDecoder::GetSHM_Locked(
|
| // queue is almost empty.
|
| if (num_shm_buffers_ < kMaxNumSharedMemorySegments &&
|
| (ret == NULL || available_shm_segments_.size() <= 1)) {
|
| - vda_loop_proxy_->PostTask(
|
| + vda_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&RTCVideoDecoder::CreateSHM, weak_this_, 1, min_size));
|
| }
|
| @@ -723,7 +723,7 @@ void RTCVideoDecoder::PutSHM_Locked(scoped_ptr<SHMBuffer> shm_buffer) {
|
| }
|
|
|
| void RTCVideoDecoder::CreateSHM(int number, size_t min_size) {
|
| - DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
|
| + DCHECK(vda_task_runner_->BelongsToCurrentThread());
|
| DVLOG(2) << "CreateSHM. size=" << min_size;
|
| int number_to_allocate;
|
| {
|
|
|