Commit 6564ee9d authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2(s)vda: stop accessing device members from child thread

The V4L2 device members are currently accessed in the GL/EGL image
creation method, which runs on the child thread. But these members
belong to the decoder thread and are not thread-safe.

Fix this by passing the device used to create the GL/EGL image to the
creation method. That way the member is accessed from the decoder
thread, and the only thing that happens in the child thread is the call
to V4L2Device::Create(E)GLImage, which is supposed to take place there.

BUG=None
TEST=video.Seek.switch_vp8 passing on Kevin.
TEST=video.Seek.switch_vp8 passing on Hana.
TEST=video.Seek.switch_h264 passing on Krane.

Change-Id: Ie94745c1215989db77e85896ac1fda69cf43a080
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026853
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739388}
parent b7559455
...@@ -1390,6 +1390,7 @@ void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffersTask( ...@@ -1390,6 +1390,7 @@ void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffersTask(
} }
void V4L2SliceVideoDecodeAccelerator::CreateGLImageFor( void V4L2SliceVideoDecodeAccelerator::CreateGLImageFor(
scoped_refptr<V4L2Device> gl_device,
size_t buffer_index, size_t buffer_index,
int32_t picture_buffer_id, int32_t picture_buffer_id,
gfx::NativePixmapHandle handle, gfx::NativePixmapHandle handle,
...@@ -1414,8 +1415,6 @@ void V4L2SliceVideoDecodeAccelerator::CreateGLImageFor( ...@@ -1414,8 +1415,6 @@ void V4L2SliceVideoDecodeAccelerator::CreateGLImageFor(
return; return;
} }
V4L2Device* gl_device =
image_processor_device_ ? image_processor_device_.get() : device_.get();
scoped_refptr<gl::GLImage> gl_image = scoped_refptr<gl::GLImage> gl_image =
gl_device->CreateGLImage(visible_size, fourcc, std::move(handle)); gl_device->CreateGLImage(visible_size, fourcc, std::move(handle));
if (!gl_image) { if (!gl_image) {
...@@ -1583,9 +1582,9 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -1583,9 +1582,9 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask(
child_task_runner_->PostTask( child_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&V4L2SliceVideoDecodeAccelerator::CreateGLImageFor, base::BindOnce(&V4L2SliceVideoDecodeAccelerator::CreateGLImageFor,
weak_this_, index, picture_buffer_id, std::move(handle), weak_this_, device_, index, picture_buffer_id,
iter->client_texture_id, iter->texture_id, std::move(handle), iter->client_texture_id,
decoder_->GetVisibleRect().size(), iter->texture_id, decoder_->GetVisibleRect().size(),
*gl_image_format_fourcc_)); *gl_image_format_fourcc_));
} }
...@@ -2245,7 +2244,8 @@ void V4L2SliceVideoDecodeAccelerator::FrameProcessed( ...@@ -2245,7 +2244,8 @@ void V4L2SliceVideoDecodeAccelerator::FrameProcessed(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&V4L2SliceVideoDecodeAccelerator::CreateGLImageFor, weak_this_, &V4L2SliceVideoDecodeAccelerator::CreateGLImageFor, weak_this_,
ip_buffer_index, ip_output_record.picture_id, image_processor_device_, ip_buffer_index,
ip_output_record.picture_id,
CreateGpuMemoryBufferHandle(frame.get()).native_pixmap_handle, CreateGpuMemoryBufferHandle(frame.get()).native_pixmap_handle,
ip_output_record.client_texture_id, ip_output_record.texture_id, ip_output_record.client_texture_id, ip_output_record.texture_id,
decoder_->GetVisibleRect().size(), *gl_image_format_fourcc_)); decoder_->GetVisibleRect().size(), *gl_image_format_fourcc_));
......
...@@ -270,12 +270,13 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecodeAccelerator ...@@ -270,12 +270,13 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecodeAccelerator
VideoPixelFormat pixel_format, VideoPixelFormat pixel_format,
gfx::NativePixmapHandle handle); gfx::NativePixmapHandle handle);
// Create a GLImage for the buffer associated with V4L2 |buffer_index| and // Create a GLImage on |gl_device| for the buffer associated with V4L2
// for |picture_buffer_id|, backed by |handle|. // |buffer_index| and |picture_buffer_id|, backed by |handle|.
// The GLImage will be associated |client_texture_id| in gles2 decoder and is // The GLImage will be associated |client_texture_id| in gles2 decoder and is
// of format |fourcc|. |visible_size| is the size in pixels that the GL device // of format |fourcc|. |visible_size| is the size in pixels that the GL device
// will be able to see. // will be able to see.
void CreateGLImageFor(size_t buffer_index, void CreateGLImageFor(scoped_refptr<V4L2Device> gl_device,
size_t buffer_index,
int32_t picture_buffer_id, int32_t picture_buffer_id,
gfx::NativePixmapHandle handle, gfx::NativePixmapHandle handle,
GLuint client_texture_id, GLuint client_texture_id,
......
...@@ -467,6 +467,7 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffersTask( ...@@ -467,6 +467,7 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffersTask(
} }
void V4L2VideoDecodeAccelerator::CreateEGLImageFor( void V4L2VideoDecodeAccelerator::CreateEGLImageFor(
scoped_refptr<V4L2Device> egl_device,
size_t buffer_index, size_t buffer_index,
int32_t picture_buffer_id, int32_t picture_buffer_id,
gfx::NativePixmapHandle handle, gfx::NativePixmapHandle handle,
...@@ -492,8 +493,6 @@ void V4L2VideoDecodeAccelerator::CreateEGLImageFor( ...@@ -492,8 +493,6 @@ void V4L2VideoDecodeAccelerator::CreateEGLImageFor(
gl::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0); gl::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0);
V4L2Device* egl_device =
image_processor_device_ ? image_processor_device_.get() : device_.get();
EGLImageKHR egl_image = egl_device->CreateEGLImage( EGLImageKHR egl_image = egl_device->CreateEGLImage(
egl_display_, gl_context->GetHandle(), texture_id, visible_size, egl_display_, gl_context->GetHandle(), texture_id, visible_size,
buffer_index, fourcc, std::move(handle)); buffer_index, fourcc, std::move(handle));
...@@ -719,7 +718,7 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -719,7 +718,7 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
child_task_runner_->PostTask( child_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&V4L2VideoDecodeAccelerator::CreateEGLImageFor, base::BindOnce(&V4L2VideoDecodeAccelerator::CreateEGLImageFor,
weak_this_, index, picture_buffer_id, weak_this_, device_, index, picture_buffer_id,
std::move(handle), iter->texture_id, visible_size_, std::move(handle), iter->texture_id, visible_size_,
*egl_image_format_fourcc_)); *egl_image_format_fourcc_));
...@@ -2706,7 +2705,8 @@ void V4L2VideoDecodeAccelerator::FrameProcessed( ...@@ -2706,7 +2705,8 @@ void V4L2VideoDecodeAccelerator::FrameProcessed(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&V4L2VideoDecodeAccelerator::CreateEGLImageFor, weak_this_, &V4L2VideoDecodeAccelerator::CreateEGLImageFor, weak_this_,
ip_buffer_index, ip_output_record.picture_id, image_processor_device_, ip_buffer_index,
ip_output_record.picture_id,
CreateGpuMemoryBufferHandle(frame.get()).native_pixmap_handle, CreateGpuMemoryBufferHandle(frame.get()).native_pixmap_handle,
ip_output_record.texture_id, visible_size_, ip_output_record.texture_id, visible_size_,
*egl_image_format_fourcc_)); *egl_image_format_fourcc_));
......
...@@ -250,12 +250,13 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator ...@@ -250,12 +250,13 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator
VideoPixelFormat pixel_format, VideoPixelFormat pixel_format,
gfx::NativePixmapHandle handle); gfx::NativePixmapHandle handle);
// Create an EGLImage for the buffer associated with V4L2 |buffer_index| and // Create an EGLImage on |egl_device| for the buffer associated with V4L2
// for |picture_buffer_id|, and backed by |handle|. // |buffer_index| and |picture_buffer_id|, backed by |handle|.
// The buffer should be bound to |texture_id| and is of format described by // The buffer should be bound to |texture_id| and is of format described by
// |fourcc|. |visible_size| is the size in pixels that the EGL device will be // |fourcc|. |visible_size| is the size in pixels that the EGL device will be
// able to see. // able to see.
void CreateEGLImageFor(size_t buffer_index, void CreateEGLImageFor(scoped_refptr<V4L2Device> egl_device,
size_t buffer_index,
int32_t picture_buffer_id, int32_t picture_buffer_id,
gfx::NativePixmapHandle handle, gfx::NativePixmapHandle handle,
GLuint texture_id, GLuint texture_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment