Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: media/gpu/v4l2_jpeg_decode_accelerator.cc

Issue 2398883002: Add support for multiple V4L2 video devices of the same type. (Closed)
Patch Set: Fixes for image processor. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/gpu/v4l2_jpeg_decode_accelerator.cc
diff --git a/media/gpu/v4l2_jpeg_decode_accelerator.cc b/media/gpu/v4l2_jpeg_decode_accelerator.cc
index b3109191e150e665911354e8fd7965368a789eb9..f47617408aa6e1da381261c3e3454d9d045cdbe9 100644
--- a/media/gpu/v4l2_jpeg_decode_accelerator.cc
+++ b/media/gpu/v4l2_jpeg_decode_accelerator.cc
@@ -187,6 +187,11 @@ void V4L2JpegDecodeAccelerator::PostNotifyError(int32_t bitstream_buffer_id,
bool V4L2JpegDecodeAccelerator::Initialize(Client* client) {
DCHECK(child_task_runner_->BelongsToCurrentThread());
+ if (!device_->Open(V4L2_PIX_FMT_JPEG)) {
+ LOG(ERROR) << "Failed to open device";
+ return false;
+ }
+
// Capabilities check.
struct v4l2_capability caps;
const __u32 kCapsRequired = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
@@ -254,15 +259,12 @@ void V4L2JpegDecodeAccelerator::Decode(
}
bool V4L2JpegDecodeAccelerator::IsSupported() {
- v4l2_fmtdesc fmtdesc;
- memset(&fmtdesc, 0, sizeof(fmtdesc));
- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ scoped_refptr<V4L2Device> device =
+ V4L2Device::Create(V4L2Device::Type::kJpegDecoder);
+ if (!device)
+ return false;
- for (; device_->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) {
- if (fmtdesc.pixelformat == V4L2_PIX_FMT_JPEG)
- return true;
- }
- return false;
+ return device->IsJpegDecodingSupported();
}
void V4L2JpegDecodeAccelerator::DecodeTask(
@@ -449,6 +451,11 @@ void V4L2JpegDecodeAccelerator::DestroyInputBuffers() {
DCHECK(decoder_task_runner_->BelongsToCurrentThread());
DCHECK(!input_streamon_);
+ free_input_buffers_.clear();
+
+ if (input_buffer_map_.empty())
kcwu 2016/10/06 10:40:00 Is this only for optimization? If so, how about se
Pawel Osciak 2016/10/07 08:30:24 It's possible for this class to be created without
+ return;
+
if (input_streamon_) {
__u32 type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMOFF, &type);
@@ -468,13 +475,17 @@ void V4L2JpegDecodeAccelerator::DestroyInputBuffers() {
IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs);
input_buffer_map_.clear();
- free_input_buffers_.clear();
}
void V4L2JpegDecodeAccelerator::DestroyOutputBuffers() {
DCHECK(decoder_task_runner_->BelongsToCurrentThread());
DCHECK(!output_streamon_);
+ free_output_buffers_.clear();
+
+ if (output_buffer_map_.empty())
+ return;
+
if (output_streamon_) {
__u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
IOCTL_OR_ERROR_RETURN(VIDIOC_STREAMOFF, &type);
@@ -494,7 +505,6 @@ void V4L2JpegDecodeAccelerator::DestroyOutputBuffers() {
IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs);
output_buffer_map_.clear();
- free_output_buffers_.clear();
}
void V4L2JpegDecodeAccelerator::DevicePollTask() {

Powered by Google App Engine
This is Rietveld 408576698