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

Unified Diff: content/renderer/media/rtc_video_decoder.cc

Issue 65803002: Replace MessageLoopProxy with SingleThreadTaskRunner for media/filters/ + associated code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1c8d6008bcadd65892c23b85ef3435b5ddacdb79..aa32aae8a955c71b2c1ca71c2bb34737a7790615 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -74,7 +74,7 @@ RTCVideoDecoder::BufferData::~BufferData() {}
RTCVideoDecoder::RTCVideoDecoder(
const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories)
: factories_(factories),
- vda_loop_proxy_(factories->GetMessageLoop()),
+ vda_task_runner_(factories->GetTaskRunner()),
decoder_texture_target_(0),
next_picture_buffer_id_(0),
state_(UNINITIALIZED),
@@ -83,25 +83,24 @@ RTCVideoDecoder::RTCVideoDecoder(
next_bitstream_buffer_id_(0),
reset_bitstream_buffer_id_(ID_INVALID),
weak_factory_(this) {
- DCHECK(!vda_loop_proxy_->BelongsToCurrentThread());
-
+ DCHECK(!vda_task_runner_->BelongsToCurrentThread());
weak_this_ = weak_factory_.GetWeakPtr();
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 {
@@ -147,7 +146,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();
}
@@ -168,11 +167,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);
}
@@ -258,7 +257,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;
}
@@ -292,7 +291,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;
@@ -306,7 +305,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_)
@@ -341,7 +340,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);
@@ -369,7 +368,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());
@@ -442,7 +441,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);
@@ -467,7 +466,7 @@ void RTCVideoDecoder::NotifyFlushDone() {
}
void RTCVideoDecoder::NotifyResetDone() {
- DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
+ DCHECK(vda_task_runner_->BelongsToCurrentThread());
DVLOG(3) << "NotifyResetDone";
if (!vda_)
@@ -483,7 +482,7 @@ void RTCVideoDecoder::NotifyResetDone() {
}
void RTCVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) {
- DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
+ DCHECK(vda_task_runner_->BelongsToCurrentThread());
if (!vda_)
return;
@@ -499,7 +498,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();
@@ -507,13 +506,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;
@@ -635,7 +634,7 @@ void RTCVideoDecoder::MovePendingBuffersToDecodeBuffers() {
}
void RTCVideoDecoder::ResetInternal() {
- DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
+ DCHECK(vda_task_runner_->BelongsToCurrentThread());
DVLOG(2) << "ResetInternal";
if (vda_)
vda_->Reset();
@@ -643,7 +642,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_)
@@ -672,7 +671,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();
@@ -692,7 +691,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();
@@ -713,7 +712,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));
}
@@ -725,7 +724,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;
{
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698