| Index: content/common/gpu/media/v4l2_video_encode_accelerator.cc
|
| diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.cc b/content/common/gpu/media/v4l2_video_encode_accelerator.cc
|
| index fe39906895adf49416f73ac8d4fbd267f7f2d3f5..7f47908fb0338f7a2dae86cf3475954a7299d928 100644
|
| --- a/content/common/gpu/media/v4l2_video_encode_accelerator.cc
|
| +++ b/content/common/gpu/media/v4l2_video_encode_accelerator.cc
|
| @@ -11,6 +11,7 @@
|
|
|
| #include "base/callback.h"
|
| #include "base/command_line.h"
|
| +#include "base/message_loop/message_loop_proxy.h"
|
| #include "base/numerics/safe_conversions.h"
|
| #include "base/trace_event/trace_event.h"
|
| #include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
|
| @@ -69,7 +70,7 @@
|
|
|
| V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator(
|
| const scoped_refptr<V4L2Device>& device)
|
| - : child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
| + : child_message_loop_proxy_(base::MessageLoopProxy::current()),
|
| output_buffer_byte_size_(0),
|
| device_input_format_(media::VideoFrame::UNKNOWN),
|
| input_planes_count_(0),
|
| @@ -114,7 +115,7 @@
|
| client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
|
| client_ = client_ptr_factory_->GetWeakPtr();
|
|
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK_EQ(encoder_state_, kUninitialized);
|
|
|
| struct v4l2_capability caps;
|
| @@ -172,12 +173,14 @@
|
|
|
| encoder_state_ = kInitialized;
|
|
|
| - child_task_runner_->PostTask(
|
| + child_message_loop_proxy_->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&Client::RequireBitstreamBuffers, client_, kInputBufferCount,
|
| - image_processor_.get()
|
| - ? image_processor_->input_allocated_size()
|
| - : input_allocated_size_,
|
| + base::Bind(&Client::RequireBitstreamBuffers,
|
| + client_,
|
| + kInputBufferCount,
|
| + image_processor_.get() ?
|
| + image_processor_->input_allocated_size() :
|
| + input_allocated_size_,
|
| output_buffer_byte_size_));
|
| return true;
|
| }
|
| @@ -191,7 +194,7 @@
|
| const scoped_refptr<media::VideoFrame>& frame,
|
| bool force_keyframe) {
|
| DVLOG(3) << "Encode(): force_keyframe=" << force_keyframe;
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| if (image_processor_) {
|
| image_processor_->Process(
|
| @@ -212,7 +215,7 @@
|
| void V4L2VideoEncodeAccelerator::UseOutputBitstreamBuffer(
|
| const media::BitstreamBuffer& buffer) {
|
| DVLOG(3) << "UseOutputBitstreamBuffer(): id=" << buffer.id();
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| if (buffer.size() < output_buffer_byte_size_) {
|
| NOTIFY_ERROR(kInvalidArgumentError);
|
| @@ -240,7 +243,7 @@
|
| uint32 framerate) {
|
| DVLOG(3) << "RequestEncodingParametersChange(): bitrate=" << bitrate
|
| << ", framerate=" << framerate;
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| encoder_thread_.message_loop()->PostTask(
|
| FROM_HERE,
|
| @@ -253,7 +256,7 @@
|
|
|
| void V4L2VideoEncodeAccelerator::Destroy() {
|
| DVLOG(3) << "Destroy()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| // We're destroying; cancel all callbacks.
|
| client_ptr_factory_.reset();
|
| @@ -318,7 +321,7 @@
|
| void V4L2VideoEncodeAccelerator::FrameProcessed(
|
| bool force_keyframe,
|
| const scoped_refptr<media::VideoFrame>& frame) {
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DVLOG(3) << "FrameProcessed(): force_keyframe=" << force_keyframe;
|
|
|
| encoder_thread_.message_loop()->PostTask(
|
| @@ -581,10 +584,13 @@
|
| DVLOG(3) << "Dequeue(): returning "
|
| "bitstream_buffer_id=" << output_record.buffer_ref->id
|
| << ", size=" << output_size << ", key_frame=" << key_frame;
|
| - child_task_runner_->PostTask(
|
| + child_message_loop_proxy_->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&Client::BitstreamBufferReady, client_,
|
| - output_record.buffer_ref->id, output_size, key_frame));
|
| + base::Bind(&Client::BitstreamBufferReady,
|
| + client_,
|
| + output_record.buffer_ref->id,
|
| + output_size,
|
| + key_frame));
|
| output_record.at_device = false;
|
| output_record.buffer_ref.reset();
|
| free_output_buffers_.push_back(dqbuf.index);
|
| @@ -768,10 +774,11 @@
|
| void V4L2VideoEncodeAccelerator::NotifyError(Error error) {
|
| DVLOG(1) << "NotifyError(): error=" << error;
|
|
|
| - if (!child_task_runner_->BelongsToCurrentThread()) {
|
| - child_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::NotifyError,
|
| - weak_this_, error));
|
| + if (!child_message_loop_proxy_->BelongsToCurrentThread()) {
|
| + child_message_loop_proxy_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &V4L2VideoEncodeAccelerator::NotifyError, weak_this_, error));
|
| return;
|
| }
|
|
|
| @@ -836,7 +843,7 @@
|
|
|
| bool V4L2VideoEncodeAccelerator::SetOutputFormat(
|
| media::VideoCodecProfile output_profile) {
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!input_streamon_);
|
| DCHECK(!output_streamon_);
|
|
|
| @@ -871,7 +878,7 @@
|
| bool V4L2VideoEncodeAccelerator::NegotiateInputFormat(
|
| media::VideoFrame::Format input_format) {
|
| DVLOG(3) << "NegotiateInputFormat()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!input_streamon_);
|
| DCHECK(!output_streamon_);
|
|
|
| @@ -931,7 +938,7 @@
|
| media::VideoFrame::Format input_format,
|
| media::VideoCodecProfile output_profile) {
|
| DVLOG(3) << "SetFormats()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!input_streamon_);
|
| DCHECK(!output_streamon_);
|
|
|
| @@ -1071,7 +1078,7 @@
|
|
|
| bool V4L2VideoEncodeAccelerator::CreateOutputBuffers() {
|
| DVLOG(3) << "CreateOutputBuffers()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!output_streamon_);
|
|
|
| struct v4l2_requestbuffers reqbufs;
|
| @@ -1113,7 +1120,7 @@
|
|
|
| void V4L2VideoEncodeAccelerator::DestroyInputBuffers() {
|
| DVLOG(3) << "DestroyInputBuffers()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!input_streamon_);
|
|
|
| struct v4l2_requestbuffers reqbufs;
|
| @@ -1129,7 +1136,7 @@
|
|
|
| void V4L2VideoEncodeAccelerator::DestroyOutputBuffers() {
|
| DVLOG(3) << "DestroyOutputBuffers()";
|
| - DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
|
| DCHECK(!output_streamon_);
|
|
|
| for (size_t i = 0; i < output_buffer_map_.size(); ++i) {
|
|
|