Chromium Code Reviews| 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 1d5cf8ee6cb11d9b4e7222f4b08d7089e7f2b47e..21f4d95a22c738b8386383bc812a61cd49498a0f 100644 |
| --- a/media/gpu/v4l2_video_decode_accelerator.cc |
| +++ b/media/gpu/v4l2_video_decode_accelerator.cc |
| @@ -274,38 +274,48 @@ bool V4L2VideoDecodeAccelerator::Initialize(const Config& config, |
| if (!SetupFormats()) |
| return false; |
| - // Subscribe to the resolution change event. |
| - struct v4l2_event_subscription sub; |
| - memset(&sub, 0, sizeof(sub)); |
| - sub.type = V4L2_EVENT_SOURCE_CHANGE; |
| - IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_SUBSCRIBE_EVENT, &sub); |
| - |
| if (video_profile_ >= H264PROFILE_MIN && video_profile_ <= H264PROFILE_MAX) { |
| decoder_h264_parser_.reset(new H264Parser()); |
| } |
| - if (!CreateInputBuffers()) |
| - return false; |
| - |
| - decoder_cmd_supported_ = IsDecoderCmdSupported(); |
| - |
| if (!decoder_thread_.Start()) { |
| LOGF(ERROR) << "decoder thread failed to start"; |
| return false; |
| } |
| - decoder_state_ = kInitialized; |
| output_mode_ = config.output_mode; |
| - // StartDevicePoll will NOTIFY_ERROR on failure, so IgnoreResult is fine here. |
| + // InitializeTask will NOTIFY_ERROR on failure. |
| decoder_thread_.task_runner()->PostTask( |
| - FROM_HERE, base::Bind(base::IgnoreResult( |
| - &V4L2VideoDecodeAccelerator::StartDevicePoll), |
| + FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::InitializeTask, |
| base::Unretained(this))); |
| return true; |
| } |
| +void V4L2VideoDecodeAccelerator::InitializeTask() { |
| + DVLOGF(3); |
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
|
kcwu
2016/11/28 06:31:14
DCHECK_EQ(decoder_state_, kUninitialized);
wuchengli
2016/11/28 09:03:19
Done.
|
| + |
| + // Subscribe to the resolution change event. |
| + struct v4l2_event_subscription sub; |
| + memset(&sub, 0, sizeof(sub)); |
| + sub.type = V4L2_EVENT_SOURCE_CHANGE; |
| + IOCTL_OR_ERROR_RETURN(VIDIOC_SUBSCRIBE_EVENT, &sub); |
| + |
| + if (!CreateInputBuffers()) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| + return; |
| + } |
| + |
| + decoder_cmd_supported_ = IsDecoderCmdSupported(); |
| + |
| + if (!StartDevicePoll()) |
| + return; |
| + |
| + decoder_state_ = kInitialized; |
| +} |
| + |
| void V4L2VideoDecodeAccelerator::Decode( |
| const BitstreamBuffer& bitstream_buffer) { |
| DVLOGF(1) << "input_id=" << bitstream_buffer.id() |
| @@ -2129,6 +2139,7 @@ gfx::Size V4L2VideoDecodeAccelerator::GetVisibleSize( |
| bool V4L2VideoDecodeAccelerator::CreateInputBuffers() { |
| DVLOGF(3); |
| + DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| // We always run this as we prepare to initialize. |
| DCHECK_EQ(decoder_state_, kUninitialized); |
| DCHECK(!input_streamon_); |