[cheese/wip/hadess/misc-fixes: 2/2] Fix warning when v4l device doesn't have a path
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/wip/hadess/misc-fixes: 2/2] Fix warning when v4l device doesn't have a path
- Date: Sun, 6 Feb 2022 18:16:11 +0000 (UTC)
commit ddee436de9acb758ca588a326b66cf26cee41e50
Author: Bastien Nocera <hadess hadess net>
Date: Sun Feb 6 18:54:53 2022 +0100
Fix warning when v4l device doesn't have a path
#0 0x00007ffff7e4cf77 in g_logv () at /lib64/libglib-2.0.so.0
#1 0x00007ffff7e4d233 in g_log () at /lib64/libglib-2.0.so.0
#2 0x00007ffff7f6b37b in g_value_dup_string () at /lib64/libgobject-2.0.so.0
#3 0x00007ffff7fb601c in cheese_camera_device_set_property (object=0x6c4360, prop_id=3,
value=0x7fffffffc6a0, pspec=0x6c6a40) at
../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device.c:635
#4 0x00007ffff7f50a46 in object_set_property () at /lib64/libgobject-2.0.so.0
#5 0x00007ffff7f50e14 in g_object_new_internal () at /lib64/libgobject-2.0.so.0
#6 0x00007ffff7f522c8 in g_object_new_valist () at /lib64/libgobject-2.0.so.0
#7 0x00007ffff7a5921e in g_initable_new_valist () at /lib64/libgio-2.0.so.0
#8 0x00007ffff7a592ed in g_initable_new () at /lib64/libgio-2.0.so.0
#9 0x00007ffff7fb674e in cheese_camera_device_new (device=0x7fffec0058c0, error=0x7fffffffcc28) at
../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device.c:781
#10 0x00007ffff7fb6e68 in cheese_camera_device_monitor_set_up_device (device=0x7fffec0058c0) at
../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device-monitor.c:96
#11 cheese_camera_device_monitor_added (monitor=0x6c7c20, device=0x7fffec0058c0) at
../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device-monitor.c:117
#12 0x00007ffff7fb7058 in cheese_camera_device_monitor_add_devices (data=0x7fffec0058c0,
user_data=<optimized out>) at ../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device-monitor.c:189
#13 0x00007ffff7e42840 in g_list_foreach () at /lib64/libglib-2.0.so.0
#14 0x00007ffff7fb7311 in cheese_camera_device_monitor_coldplug (monitor=0x6c7c20) at
../../../../Projects/jhbuild/cheese/libcheese/cheese-camera-device-monitor.c:221
#15 0x0000000000401d4f in cameradevicemonitor_create () at
../../../../Projects/jhbuild/cheese/tests/test-libcheese.c:39
#16 0x00007ffff7e71bd6 in g_test_run_suite_internal () at /lib64/libglib-2.0.so.0
#17 0x00007ffff7e718fb in g_test_run_suite_internal () at /lib64/libglib-2.0.so.0
#18 0x00007ffff7e718fb in g_test_run_suite_internal () at /lib64/libglib-2.0.so.0
#19 0x00007ffff7e720aa in g_test_run_suite () at /lib64/libglib-2.0.so.0
#20 0x00007ffff7e720d1 in g_test_run () at /lib64/libglib-2.0.so.0
#21 0x00000000004012b8 in main (argc=<optimized out>, argv=<optimized out>) at
../../../../Projects/jhbuild/cheese/tests/test-libcheese.c:231
The api.v4l2.path might not always be available, so avoid using it when
not present.
gst-device-monitor-1.0 on my system:
name : USB2.0 FHD UVC WebCam: USB2.0 F
class : Video/Source
caps : video/x-raw, format=YUY2, width=640, height=480, pixel-aspect-ratio=1/1, framerate=30/1
video/x-raw, format=YUY2, width=640, height=360, pixel-aspect-ratio=1/1, framerate=30/1
video/x-raw, format=YUY2, width=352, height=288, pixel-aspect-ratio=1/1, framerate=30/1
video/x-raw, format=YUY2, width=320, height=240, pixel-aspect-ratio=1/1, framerate=30/1
video/x-raw, format=YUY2, width=176, height=144, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=1920, height=1080, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=1280, height=720, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=848, height=480, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=640, height=480, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=640, height=360, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=352, height=288, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=320, height=240, pixel-aspect-ratio=1/1, framerate=30/1
image/jpeg, width=176, height=144, pixel-aspect-ratio=1/1, framerate=30/1
properties:
udev-probed = true
device.bus_path = pci-0000:00:14.0-usb-0:1.4:1.0
sysfs.path =
/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4/1-1.4:1.0/video4linux/video0
device.bus = usb
device.subsystem = video4linux
device.vendor.id = 04f2
device.vendor.name = "SunplusIT\\x20Inc"
device.product.id = b612
device.product.name = "USB2.0\ FHD\ UVC\ WebCam:\ USB2.0\ F"
device.serial = SunplusIT_Inc_USB2.0_FHD_UVC_WebCam_01.00.00
device.capabilities = :capture:
device.api = v4l2
device.path = /dev/video0
v4l2.device.driver = uvcvideo
v4l2.device.card = "USB2.0\ FHD\ UVC\ WebCam:\ USB2.0\ F"
v4l2.device.bus_info = usb-0000:00:14.0-1.4
v4l2.device.version = 331538 (0x00050f12)
v4l2.device.capabilities = 2225078273 (0x84a00001)
v4l2.device.device_caps = 69206017 (0x04200001)
gst-launch-1.0 v4l2src ! ...
Fixes: 9f0825c3169047da75d3fe91a3cb02bfe6fb7f25
libcheese/cheese-camera-device.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
index f11dd828..95187801 100644
--- a/libcheese/cheese-camera-device.c
+++ b/libcheese/cheese-camera-device.c
@@ -618,6 +618,7 @@ cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue
{
CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
CheeseCameraDevicePrivate *priv = cheese_camera_device_get_instance_private (device);
+ const GValue *tmp;
switch (prop_id)
{
@@ -626,13 +627,15 @@ cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue
priv->name = g_value_dup_string (value);
break;
case PROP_DEVICE:
- if (priv->device)
- g_object_unref (priv->device);
+ g_clear_object (&priv->device);
priv->device = g_value_dup_object (value);
g_free (priv->name);
priv->name = gst_device_get_display_name (priv->device);
- g_free (priv->path);
- priv->path = g_value_dup_string (gst_structure_get_value (gst_device_get_properties (priv->device),
"api.v4l2.path"));
+ tmp = gst_structure_get_value (gst_device_get_properties (priv->device), "api.v4l2.path");
+ if (tmp) {
+ g_clear_pointer (&priv->path, g_free);
+ priv->path = g_value_dup_string (tmp);
+ }
break;
case PROP_PATH:
g_free (priv->path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]