From f9cbbd7b37fc70d471911ae91c7cdd009084bbc3 Mon Sep 17 00:00:00 2001 From: psykose Date: Sun, 29 Sep 2024 04:24:39 +0200 Subject: [PATCH] main/snapshot: add missing runtime dep, fix a crash --- main/snapshot/patches/crash.patch | 114 ++++++++++++++++++++++++++++++ main/snapshot/template.py | 3 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 main/snapshot/patches/crash.patch diff --git a/main/snapshot/patches/crash.patch b/main/snapshot/patches/crash.patch new file mode 100644 index 0000000000..6aa8e7d0e7 --- /dev/null +++ b/main/snapshot/patches/crash.patch @@ -0,0 +1,114 @@ +Patch-Source: https://gitlab.gnome.org/GNOME/snapshot/-/merge_requests/316 +-- +From 2cf4643b0abc1a238f8f38c3eb8250a347ccb10d Mon Sep 17 00:00:00 2001 +From: "Jan Alexander Steffens (heftig)" +Date: Sat, 21 Sep 2024 09:38:23 +0200 +Subject: [PATCH] aperture: Only get devices from the pipewiredeviceprovider + +`create_element`'s parameter is for giving the produced element a name. +It does not select the element type. + +Remove the `DeviceMonitor` as it can load and start other providers that +might give us incompatible cameras while the pipewire provider is still +busy figuring out whether it should hide these other providers. + +Using a device monitor inside a device provider (which itself implicitly +feeds into the monitor) also introduces recursion, which is probably +unwise. + +Do the filtering the monitor did for us ourselves. + +Fixes: e60bdb67e7d9bad8016741ba40d6a560e2478653 +Fixes: https://gitlab.gnome.org/GNOME/snapshot/-/issues/232 +--- + aperture/src/camera.rs | 2 +- + aperture/src/device_provider.rs | 22 +++++++++++++--------- + 2 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/aperture/src/camera.rs b/aperture/src/camera.rs +index 3ce7fb67..a5119c71 100644 +--- a/aperture/src/camera.rs ++++ b/aperture/src/camera.rs +@@ -145,7 +145,7 @@ impl Camera { + } + + pub(crate) fn create_element(&self) -> Result { +- let element = self.device().create_element(Some("pipewiresrc"))?; ++ let element = self.device().create_element(None)?; + element.set_property("client-name", crate::APP_ID.get().unwrap()); + Ok(element) + } +diff --git a/aperture/src/device_provider.rs b/aperture/src/device_provider.rs +index 82d5c762..f97e608e 100644 +--- a/aperture/src/device_provider.rs ++++ b/aperture/src/device_provider.rs +@@ -28,7 +28,6 @@ mod imp { + #[properties(wrapper_type = super::DeviceProvider)] + pub struct DeviceProvider { + pub inner: OnceCell, +- pub monitor: OnceCell, + pub cameras: RefCell>, + pub bus_watch: OnceCell, + +@@ -108,10 +107,6 @@ mod imp { + + crate::ensure_init(); + +- let monitor = gst::DeviceMonitor::new(); +- monitor.add_filter(Some("Video/Source"), Some(&crate::SUPPORTED_CAPS)); +- self.monitor.set(monitor).unwrap(); +- + if let Some(provider) = gst::DeviceProviderFactory::by_name("pipewiredeviceprovider") { + self.inner.set(provider).unwrap(); + } +@@ -215,12 +210,11 @@ impl DeviceProvider { + }; + provider.start()?; + +- let monitor = imp.monitor.get().unwrap(); +- + let mut seen = HashSet::new(); +- let mut cameras = monitor ++ let mut cameras = provider + .devices() + .iter() ++ .filter(|d| is_camera(d)) + .map(crate::Camera::new) + .filter(|d| !is_ir_camera(d)) + .collect::>(); +@@ -238,7 +232,7 @@ impl DeviceProvider { + self.imp().cameras.replace(cameras); + self.items_changed(0, 0, n_items); + +- let bus = monitor.bus(); ++ let bus = provider.bus(); + let watch = bus + .add_watch_local(glib::clone!( + #[weak(rename_to = obj)] +@@ -359,6 +353,9 @@ impl DeviceProvider { + .structure() + .and_then(|s| s.get::("device").ok()) + { ++ if !is_camera(&device) { ++ return; ++ } + let device = crate::Camera::new(&device); + if !imp.has_camera(&device) { + // We ignore/filter IR cameras. +@@ -405,6 +402,13 @@ impl DeviceProvider { + } + } + ++fn is_camera(device: &gst::Device) -> bool { ++ device.has_classes("Video/Source") ++ && device ++ .caps() ++ .is_some_and(|c| c.can_intersect(&crate::SUPPORTED_CAPS)) ++} ++ + fn is_ir_camera(device: &crate::Camera) -> bool { + device + .device() +-- +GitLab + diff --git a/main/snapshot/template.py b/main/snapshot/template.py index ab1d02b99d..5667c37b87 100644 --- a/main/snapshot/template.py +++ b/main/snapshot/template.py @@ -1,6 +1,6 @@ pkgname = "snapshot" pkgver = "47.0.1" -pkgrel = 0 +pkgrel = 1 build_style = "meson" hostmakedepends = [ "appstream", @@ -21,6 +21,7 @@ "rust-std", ] depends = [ + "gst-plugins-rs-gtk4", "gstreamer-libcamera", "gstreamer-pipewire", ]