On 8/28/20 10:52 AM, Jeff Smith wrote:
Signed-off-by: Jeff Smith <whydoubt(a)gmail.com> --- dlls/qcap/v4l.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 6d67dd19be..c6a5e45831 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -222,6 +222,9 @@ static HRESULT v4l_device_get_format(struct video_capture_device *iface, AM_MEDI { struct v4l_device *device = v4l_device(iface);
+ if (!device->current_caps) + return CopyMediaType(mt, &device->caps[0].media_type); + return CopyMediaType(mt, &device->current_caps->media_type); }
@@ -406,6 +409,9 @@ static void v4l_device_init_stream(struct video_capture_device *iface) ALLOCATOR_PROPERTIES req_props, ret_props; HRESULT hr;
+ if (!device->current_caps) + set_caps(device, &device->caps[0]); +
Explanation for why to do this, either as a comment in the code or as part of a commit message, would be helpful. Patch 4/4 justifies setting current caps to NULL until it's used, but it doesn't justify this hunk. I'm not exactly sure we want to remove error checking here.
req_props.cBuffers = 3; req_props.cbBuffer = device->current_caps->video_info.bmiHeader.biWidth * device->current_caps->video_info.bmiHeader.biHeight; req_props.cbBuffer = (req_props.cbBuffer * device->current_caps->video_info.bmiHeader.biBitCount) / 8; @@ -667,14 +673,6 @@ struct video_capture_device *v4l_device_create(struct strmbase_source *pin, USHO for (i = 0; i < device->caps_count; ++i) device->caps[i].media_type.pbFormat = (BYTE *)&device->caps[i].video_info;
- if (!set_caps(device, &device->caps[0])) - { - ERR("Failed to set pixel format: %s\n", strerror(errno)); - if (!have_libv4l2) - ERR_(winediag)("You may need libv4l2 to use this device.\n"); - goto error;
The first error message is redundant, but I think the second should be retained [and probably moved into set_caps()].
- } - device->d.ops = &v4l_device_ops; device->pin = pin; device->state = State_Stopped; @@ -682,9 +680,9 @@ struct video_capture_device *v4l_device_create(struct strmbase_source *pin, USHO InitializeCriticalSection(&device->state_cs); device->state_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": v4l_device.state_cs");
- TRACE("Format: %d bpp - %dx%d.\n", device->current_caps->video_info.bmiHeader.biBitCount, - device->current_caps->video_info.bmiHeader.biWidth, - device->current_caps->video_info.bmiHeader.biHeight); + TRACE("Format: %d bpp - %dx%d.\n", device->caps[0].video_info.bmiHeader.biBitCount, + device->caps[0].video_info.bmiHeader.biWidth, + device->caps[0].video_info.bmiHeader.biHeight);
This trace isn't doing much anymore, especially since we always dump the output of v4l_device_get_format(), so it can probably just be removed, or replaced with a call to strmbase_dump_media_type() in v4l_device_init_stream().
return &device->d;