Subject: [PATCH] gnu: ungoogled-chromium: Fix WebRTC.

From: Danny Milosavljevic <[email-masked]>
Date: Fri, 25 Apr 2025 01:04:29 +0200

* gnu/packages/patches/ungoogled-chromium-fcntl-fix.patch: New file.
* gnu/packages/chromium.scm (%guix-patches): Add reference to it.
* gnu/local.mk (dist_patch_DATA): Add reference to it.

Change-Id: I91b7c3243345f6f1eda71aa4ec68faf3ef4a98f4
---
 gnu/local.mk                                  |  1 +
 gnu/packages/chromium.scm                     |  3 ++
 .../ungoogled-chromium-fcntl-fix.patch        | 28 +++++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 gnu/packages/patches/ungoogled-chromium-fcntl-fix.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 62cfe230bb..582296e3c9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2344,6 +2344,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/uftrace-fix-tests.patch			\
   %D%/packages/patches/ultrastar-deluxe-no-freesans.patch		\
   %D%/packages/patches/ungoogled-chromium-extension-search-path.patch	\
+  %D%/packages/patches/ungoogled-chromium-fcntl-fix.patch	\
   %D%/packages/patches/ungoogled-chromium-ffmpeg-compat.patch	\
   %D%/packages/patches/ungoogled-chromium-RUNPATH.patch		\
   %D%/packages/patches/ungoogled-chromium-system-ffmpeg.patch	\
diff --git a/gnu/packages/chromium.scm b/gnu/packages/chromium.scm
index 5da5f10da6..45fd719822 100644
--- a/gnu/packages/chromium.scm
+++ b/gnu/packages/chromium.scm
@@ -385,6 +385,9 @@ (define %guix-patches
   (list (local-file
          (assume-valid-file-name
           (search-patch "ungoogled-chromium-extension-search-path.patch")))
+        (local-file
+         (assume-valid-file-name
+          (search-patch "ungoogled-chromium-fcntl-fix.patch")))
         (local-file
          (assume-valid-file-name
           (search-patch "ungoogled-chromium-RUNPATH.patch")))
diff --git a/gnu/packages/patches/ungoogled-chromium-fcntl-fix.patch b/gnu/packages/patches/ungoogled-chromium-fcntl-fix.patch
new file mode 100644
index 0000000000..e9e8664b6f
--- /dev/null
+++ b/gnu/packages/patches/ungoogled-chromium-fcntl-fix.patch
@@ -0,0 +1,28 @@
+From 7b0d7f48fbffb412f0c485f86ef33b0dea605d1d Mon Sep 17 00:00:00 2001
+From: Jan Grulich <[email-masked]>
+Date: Fri, 12 May 2023 20:59:06 +0200
+Subject: [PATCH] PipeWire capturer: fix fcntl call when duplicating a file descriptor
+
+The fcntl() call has variable arguments, therefore we need to pass 0 to
+specify there are no other arguments for this call, otherwise we might
+end up with an argument that is random garbage.
+
+Bug: webrtc:15174
+Change-Id: I34f16a942d80913b667d8ade7eed557b0233be01
+Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305120
+Reviewed-by: Alexander Cooper <[email-masked]>
+Commit-Queue: Jan Grulich <[email-masked]>
+Cr-Commit-Position: refs/heads/main@{#40060}
+---
+
+--- ./third_party/webrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc.orig	2024-11-18 21:48:23.280303055 +0100
++++ ./third_party/webrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc	2024-11-18 21:48:24.860287444 +0100
+@@ -447,7 +447,7 @@
+ 
+     if (fd >= 0) {
+       pw_core_ = pw_context_connect_fd(
+-          pw_context_, fcntl(fd, F_DUPFD_CLOEXEC), nullptr, 0);
++          pw_context_, fcntl(fd, F_DUPFD_CLOEXEC, 0), nullptr, 0);
+     } else {
+       pw_core_ = pw_context_connect(pw_context_, nullptr, 0);
+     }

base-commit: a36ff7d51110403295a359e7f40c3eb42ccfd509
-- 
2.49.0