| Index: content/common/gpu/media/v4l2_video_decode_accelerator.cc
|
| diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
|
| index 3deddf07105a6aefae69a934681d3d9e8752cc0c..3554be56efc0164073897f386ac40bcd65467297 100644
|
| --- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc
|
| +++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
|
| @@ -25,7 +25,6 @@
|
| #include "media/base/media_switches.h"
|
| #include "media/filters/h264_parser.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| -#include "ui/gl/gl_context.h"
|
| #include "ui/gl/scoped_binders.h"
|
|
|
| #define NOTIFY_ERROR(x) \
|
| @@ -154,10 +153,14 @@
|
|
|
| V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator(
|
| EGLDisplay egl_display,
|
| - const GetGLContextCallback& get_gl_context_cb,
|
| - const MakeGLContextCurrentCallback& make_context_current_cb,
|
| - const scoped_refptr<V4L2Device>& device)
|
| + EGLContext egl_context,
|
| + const base::WeakPtr<Client>& io_client,
|
| + const base::Callback<bool(void)>& make_context_current,
|
| + const scoped_refptr<V4L2Device>& device,
|
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
|
| : child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
| + io_task_runner_(io_task_runner),
|
| + io_client_(io_client),
|
| decoder_thread_("V4L2DecoderThread"),
|
| decoder_state_(kUninitialized),
|
| device_(device),
|
| @@ -177,9 +180,9 @@
|
| picture_clearing_count_(0),
|
| pictures_assigned_(false, false),
|
| device_poll_thread_("V4L2DevicePollThread"),
|
| + make_context_current_(make_context_current),
|
| egl_display_(egl_display),
|
| - get_gl_context_cb_(get_gl_context_cb),
|
| - make_context_current_cb_(make_context_current_cb),
|
| + egl_context_(egl_context),
|
| video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
|
| output_format_fourcc_(0),
|
| weak_this_factory_(this) {
|
| @@ -205,11 +208,6 @@
|
| DCHECK(child_task_runner_->BelongsToCurrentThread());
|
| DCHECK_EQ(decoder_state_, kUninitialized);
|
|
|
| - if (get_gl_context_cb_.is_null() || make_context_current_cb_.is_null()) {
|
| - NOTREACHED() << "GL callbacks are required for this VDA";
|
| - return false;
|
| - }
|
| -
|
| if (config.is_encrypted) {
|
| NOTREACHED() << "Encrypted streams are not supported for this VDA";
|
| return false;
|
| @@ -224,14 +222,6 @@
|
|
|
| client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
|
| client_ = client_ptr_factory_->GetWeakPtr();
|
| - // If we haven't been set up to decode on separate thread via
|
| - // TryToSetupDecodeOnSeparateThread(), use the main thread/client for
|
| - // decode tasks.
|
| - if (!decode_task_runner_) {
|
| - decode_task_runner_ = child_task_runner_;
|
| - DCHECK(!decode_client_);
|
| - decode_client_ = client_;
|
| - }
|
|
|
| video_profile_ = config.profile;
|
|
|
| @@ -241,7 +231,7 @@
|
| }
|
|
|
| // We need the context to be initialized to query extensions.
|
| - if (!make_context_current_cb_.Run()) {
|
| + if (!make_context_current_.Run()) {
|
| LOG(ERROR) << "Initialize(): could not make context current";
|
| return false;
|
| }
|
| @@ -302,7 +292,7 @@
|
| const media::BitstreamBuffer& bitstream_buffer) {
|
| DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id()
|
| << ", size=" << bitstream_buffer.size();
|
| - DCHECK(decode_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(io_task_runner_->BelongsToCurrentThread());
|
|
|
| if (bitstream_buffer.id() < 0) {
|
| LOG(ERROR) << "Invalid bitstream_buffer, id: " << bitstream_buffer.id();
|
| @@ -334,8 +324,7 @@
|
| return;
|
| }
|
|
|
| - gfx::GLContext* gl_context = get_gl_context_cb_.Run();
|
| - if (!gl_context || !make_context_current_cb_.Run()) {
|
| + if (!make_context_current_.Run()) {
|
| LOG(ERROR) << "AssignPictureBuffers(): could not make context current";
|
| NOTIFY_ERROR(PLATFORM_FAILURE);
|
| return;
|
| @@ -375,7 +364,7 @@
|
| DCHECK_EQ(output_record.cleared, false);
|
|
|
| EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_,
|
| - gl_context->GetHandle(),
|
| + egl_context_,
|
| buffers[i].texture_id(),
|
| coded_size_,
|
| i,
|
| @@ -405,7 +394,7 @@
|
| // Must be run on child thread, as we'll insert a sync in the EGL context.
|
| DCHECK(child_task_runner_->BelongsToCurrentThread());
|
|
|
| - if (!make_context_current_cb_.Run()) {
|
| + if (!make_context_current_.Run()) {
|
| LOG(ERROR) << "ReusePictureBuffer(): could not make context current";
|
| NOTIFY_ERROR(PLATFORM_FAILURE);
|
| return;
|
| @@ -466,13 +455,7 @@
|
| delete this;
|
| }
|
|
|
| -bool V4L2VideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
|
| - const base::WeakPtr<Client>& decode_client,
|
| - const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
|
| - decode_client_ = decode_client_;
|
| - decode_task_runner_ = decode_task_runner;
|
| - return true;
|
| -}
|
| +bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; }
|
|
|
| // static
|
| media::VideoDecodeAccelerator::SupportedProfiles
|
| @@ -494,7 +477,7 @@
|
| bitstream_buffer.id());
|
|
|
| scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef(
|
| - decode_client_, decode_task_runner_,
|
| + io_client_, io_task_runner_,
|
| scoped_ptr<SharedMemoryRegion>(
|
| new SharedMemoryRegion(bitstream_buffer, true)),
|
| bitstream_buffer.id()));
|
| @@ -1287,7 +1270,7 @@
|
| // Queue up an empty buffer -- this triggers the flush.
|
| decoder_input_queue_.push(
|
| linked_ptr<BitstreamBufferRef>(new BitstreamBufferRef(
|
| - decode_client_, decode_task_runner_, nullptr, kFlushBufferId)));
|
| + io_client_, io_task_runner_, nullptr, kFlushBufferId)));
|
| decoder_flushing_ = true;
|
| SendPictureReady(); // Send all pending PictureReady.
|
|
|
| @@ -2010,12 +1993,10 @@
|
| bool cleared = pending_picture_ready_.front().cleared;
|
| const media::Picture& picture = pending_picture_ready_.front().picture;
|
| if (cleared && picture_clearing_count_ == 0) {
|
| - // This picture is cleared. It can be posted to a thread different than
|
| - // the main GPU thread to reduce latency. This should be the case after
|
| - // all pictures are cleared at the beginning.
|
| - decode_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&Client::PictureReady, decode_client_, picture));
|
| + // This picture is cleared. Post it to IO thread to reduce latency. This
|
| + // should be the case after all pictures are cleared at the beginning.
|
| + io_task_runner_->PostTask(
|
| + FROM_HERE, base::Bind(&Client::PictureReady, io_client_, picture));
|
| pending_picture_ready_.pop();
|
| } else if (!cleared || resetting_or_flushing) {
|
| DVLOG(3) << "SendPictureReady()"
|
|
|