| Index: media/gpu/v4l2_video_decode_accelerator.cc
|
| diff --git a/media/gpu/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2_video_decode_accelerator.cc
|
| index 6e5ee517d363273e158256dc17e59acee8f3db2d..cd22cbfdd7c953f40428ab02622fa4860f751a40 100644
|
| --- a/media/gpu/v4l2_video_decode_accelerator.cc
|
| +++ b/media/gpu/v4l2_video_decode_accelerator.cc
|
| @@ -18,6 +18,7 @@
|
| #include "base/command_line.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/numerics/safe_conversions.h"
|
| +#include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "base/trace_event/trace_event.h"
|
| #include "build/build_config.h"
|
| @@ -532,7 +533,7 @@ V4L2VideoDecodeAccelerator::GetSupportedProfiles() {
|
| void V4L2VideoDecodeAccelerator::DecodeTask(
|
| const BitstreamBuffer& bitstream_buffer) {
|
| DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id();
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| TRACE_EVENT1("Video Decoder", "V4L2VDA::DecodeTask", "input_id",
|
| bitstream_buffer.id());
|
| @@ -575,7 +576,7 @@ void V4L2VideoDecodeAccelerator::DecodeTask(
|
|
|
| void V4L2VideoDecodeAccelerator::DecodeBufferTask() {
|
| DVLOG(3) << "DecodeBufferTask()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::DecodeBufferTask");
|
|
|
| @@ -777,7 +778,7 @@ bool V4L2VideoDecodeAccelerator::AdvanceFrameFragment(const uint8_t* data,
|
| }
|
|
|
| void V4L2VideoDecodeAccelerator::ScheduleDecodeBufferTaskIfNeeded() {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
|
|
| // If we're behind on tasks, schedule another one.
|
| int buffers_to_decode = decoder_input_queue_.size();
|
| @@ -795,7 +796,7 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferInitial(const void* data,
|
| size_t size,
|
| size_t* endpos) {
|
| DVLOG(3) << "DecodeBufferInitial(): data=" << data << ", size=" << size;
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| DCHECK_NE(decoder_state_, kDecoding);
|
| // Initial decode. We haven't been able to get output stream format info yet.
|
| @@ -845,7 +846,7 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferInitial(const void* data,
|
| bool V4L2VideoDecodeAccelerator::DecodeBufferContinue(const void* data,
|
| size_t size) {
|
| DVLOG(3) << "DecodeBufferContinue(): data=" << data << ", size=" << size;
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_EQ(decoder_state_, kDecoding);
|
|
|
| // Both of these calls will set kError state if they fail.
|
| @@ -857,7 +858,7 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferContinue(const void* data,
|
| bool V4L2VideoDecodeAccelerator::AppendToInputFrame(const void* data,
|
| size_t size) {
|
| DVLOG(3) << "AppendToInputFrame()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| DCHECK_NE(decoder_state_, kResetting);
|
| DCHECK_NE(decoder_state_, kError);
|
| @@ -921,7 +922,7 @@ bool V4L2VideoDecodeAccelerator::AppendToInputFrame(const void* data,
|
|
|
| bool V4L2VideoDecodeAccelerator::FlushInputFrame() {
|
| DVLOG(3) << "FlushInputFrame()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| DCHECK_NE(decoder_state_, kResetting);
|
| DCHECK_NE(decoder_state_, kError);
|
| @@ -958,7 +959,7 @@ bool V4L2VideoDecodeAccelerator::FlushInputFrame() {
|
|
|
| void V4L2VideoDecodeAccelerator::ServiceDeviceTask(bool event_pending) {
|
| DVLOG(3) << "ServiceDeviceTask()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::ServiceDeviceTask");
|
|
|
| @@ -1022,7 +1023,7 @@ void V4L2VideoDecodeAccelerator::ServiceDeviceTask(bool event_pending) {
|
|
|
| void V4L2VideoDecodeAccelerator::Enqueue() {
|
| DVLOG(3) << "Enqueue()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::Enqueue");
|
|
|
| @@ -1072,7 +1073,7 @@ void V4L2VideoDecodeAccelerator::Enqueue() {
|
| }
|
|
|
| bool V4L2VideoDecodeAccelerator::DequeueResolutionChangeEvent() {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| DVLOG(3) << "DequeueResolutionChangeEvent()";
|
|
|
| @@ -1096,7 +1097,7 @@ bool V4L2VideoDecodeAccelerator::DequeueResolutionChangeEvent() {
|
|
|
| void V4L2VideoDecodeAccelerator::Dequeue() {
|
| DVLOG(3) << "Dequeue()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::Dequeue");
|
|
|
| @@ -1281,7 +1282,7 @@ void V4L2VideoDecodeAccelerator::ReusePictureBufferTask(
|
| std::unique_ptr<EGLSyncKHRRef> egl_sync_ref) {
|
| DVLOG(3) << "ReusePictureBufferTask(): picture_buffer_id="
|
| << picture_buffer_id;
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::ReusePictureBufferTask");
|
|
|
| // We run ReusePictureBufferTask even if we're in kResetting.
|
| @@ -1331,7 +1332,7 @@ void V4L2VideoDecodeAccelerator::ReusePictureBufferTask(
|
|
|
| void V4L2VideoDecodeAccelerator::FlushTask() {
|
| DVLOG(3) << "FlushTask()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::FlushTask");
|
|
|
| // Flush outstanding buffers.
|
| @@ -1360,7 +1361,7 @@ void V4L2VideoDecodeAccelerator::FlushTask() {
|
| }
|
|
|
| void V4L2VideoDecodeAccelerator::NotifyFlushDoneIfNeeded() {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| if (!decoder_flushing_)
|
| return;
|
|
|
| @@ -1409,7 +1410,7 @@ void V4L2VideoDecodeAccelerator::NotifyFlushDoneIfNeeded() {
|
|
|
| void V4L2VideoDecodeAccelerator::ResetTask() {
|
| DVLOG(3) << "ResetTask()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::ResetTask");
|
|
|
| if (decoder_state_ == kError) {
|
| @@ -1469,7 +1470,7 @@ void V4L2VideoDecodeAccelerator::ResetTask() {
|
|
|
| void V4L2VideoDecodeAccelerator::ResetDoneTask() {
|
| DVLOG(3) << "ResetDoneTask()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::ResetDoneTask");
|
|
|
| if (decoder_state_ == kError) {
|
| @@ -1529,7 +1530,7 @@ void V4L2VideoDecodeAccelerator::DestroyTask() {
|
| bool V4L2VideoDecodeAccelerator::StartDevicePoll() {
|
| DVLOG(3) << "StartDevicePoll()";
|
| DCHECK(!device_poll_thread_.IsRunning());
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
|
|
| // Start up the device poll thread and schedule its first DevicePollTask().
|
| if (!device_poll_thread_.Start()) {
|
| @@ -1551,7 +1552,7 @@ bool V4L2VideoDecodeAccelerator::StopDevicePoll() {
|
| return true;
|
|
|
| if (decoder_thread_.IsRunning())
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
|
|
| // Signal the DevicePollTask() to stop, and stop the device poll thread.
|
| if (!device_->SetDevicePollInterrupt()) {
|
| @@ -1618,7 +1619,7 @@ bool V4L2VideoDecodeAccelerator::StopInputStream() {
|
| }
|
|
|
| void V4L2VideoDecodeAccelerator::StartResolutionChange() {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_NE(decoder_state_, kUninitialized);
|
| DCHECK_NE(decoder_state_, kResetting);
|
|
|
| @@ -1643,7 +1644,7 @@ void V4L2VideoDecodeAccelerator::StartResolutionChange() {
|
| }
|
|
|
| void V4L2VideoDecodeAccelerator::FinishResolutionChange() {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_EQ(decoder_state_, kChangingResolution);
|
| DVLOG(3) << "FinishResolutionChange()";
|
|
|
| @@ -1685,7 +1686,7 @@ void V4L2VideoDecodeAccelerator::FinishResolutionChange() {
|
|
|
| void V4L2VideoDecodeAccelerator::DevicePollTask(bool poll_device) {
|
| DVLOG(3) << "DevicePollTask()";
|
| - DCHECK_EQ(device_poll_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(device_poll_thread_.task_runner()->BelongsToCurrentThread());
|
| TRACE_EVENT0("Video Decoder", "V4L2VDA::DevicePollTask");
|
|
|
| bool event_pending = false;
|
| @@ -1740,7 +1741,7 @@ void V4L2VideoDecodeAccelerator::SetErrorState(Error error) {
|
| bool V4L2VideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format,
|
| gfx::Size* visible_size,
|
| bool* again) {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
|
|
| *again = false;
|
| memset(format, 0, sizeof(*format));
|
| @@ -1773,7 +1774,7 @@ bool V4L2VideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format,
|
| bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat(
|
| const struct v4l2_format& format,
|
| const gfx::Size& visible_size) {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| output_planes_count_ = format.fmt.pix_mp.num_planes;
|
| coded_size_.SetSize(format.fmt.pix_mp.width, format.fmt.pix_mp.height);
|
| visible_size_ = visible_size;
|
| @@ -1800,7 +1801,7 @@ bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat(
|
|
|
| gfx::Size V4L2VideoDecodeAccelerator::GetVisibleSize(
|
| const gfx::Size& coded_size) {
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
|
|
| struct v4l2_crop crop_arg;
|
| memset(&crop_arg, 0, sizeof(crop_arg));
|
| @@ -2148,7 +2149,7 @@ void V4L2VideoDecodeAccelerator::ResolutionChangeDestroyBuffers() {
|
|
|
| void V4L2VideoDecodeAccelerator::SendPictureReady() {
|
| DVLOG(3) << "SendPictureReady()";
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| bool resetting_or_flushing =
|
| (decoder_state_ == kResetting || decoder_flushing_);
|
| while (pending_picture_ready_.size() > 0) {
|
| @@ -2191,7 +2192,7 @@ void V4L2VideoDecodeAccelerator::SendPictureReady() {
|
|
|
| void V4L2VideoDecodeAccelerator::PictureCleared() {
|
| DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_;
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_GT(picture_clearing_count_, 0);
|
| picture_clearing_count_--;
|
| SendPictureReady();
|
| @@ -2201,7 +2202,7 @@ void V4L2VideoDecodeAccelerator::FrameProcessed(int32_t bitstream_buffer_id,
|
| int output_buffer_index) {
|
| DVLOG(3) << __func__ << ": output_buffer_index=" << output_buffer_index
|
| << ", bitstream_buffer_id=" << bitstream_buffer_id;
|
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
|
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
|
| DCHECK_GE(output_buffer_index, 0);
|
| DCHECK_LT(output_buffer_index, static_cast<int>(output_buffer_map_.size()));
|
|
|
|
|