summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mader <robert.mader@posteo.de>2023-01-03 17:51:31 +0100
committerDavid King <amigadave@amigadave.com>2023-01-04 09:59:03 +0000
commitb9fc5abdb461c364a9c1f634a01c8c2fe87e3213 (patch)
tree12737d499b13c68b840ca1eaa8015ca23585d3a7
parent20f9422502757b2ec626dffabf4ec45ab471799b (diff)
downloadcheese-b9fc5abdb461c364a9c1f634a01c8c2fe87e3213.tar.gz
device-monitor: Stop createing duplicated CameraDevices
Devices detected in `cheese_camera_device_monitor_coldplug()` may get duplicated, as Gstreamer will emit `GST_MESSAGE_DEVICE_ADDED` for them. While this issue could be fixed by reorganizing the initialization code, let's go with a simple and robust solution and check if a `CheeseCameraDevice` using the `GstDevice` is already present.
-rw-r--r--libcheese/cheese-camera-device-monitor.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libcheese/cheese-camera-device-monitor.c b/libcheese/cheese-camera-device-monitor.c
index 87c48ccb..a2c3565c 100644
--- a/libcheese/cheese-camera-device-monitor.c
+++ b/libcheese/cheese-camera-device-monitor.c
@@ -114,7 +114,16 @@ static void
cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
GstDevice *device)
{
- CheeseCameraDevice *newdev = cheese_camera_device_monitor_set_up_device (device);
+ CheeseCameraDevice *olddev;
+ CheeseCameraDevice *newdev;
+
+ olddev = g_object_get_data (G_OBJECT (device), "cheese-camera-device");
+ if (olddev) {
+ GST_DEBUG ("Ignoring duplicate device %" GST_PTR_FORMAT, device);
+ return;
+ }
+
+ newdev = cheese_camera_device_monitor_set_up_device (device);
/* Ignore non-video devices, GNOME bug #677544. */
if (newdev) {
g_object_set_data (G_OBJECT (device), "cheese-camera-device", newdev);