commit: 211924340dc1f91d4613841fa391d2c44e763dac Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Tue Sep 30 11:55:08 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Sep 30 11:56:30 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=21192434
media-video/pipewire: backport patches to 1.4.8 Selection of cherry-picks from the 1.4 branch. Adjust the 1.4.8 ebuild to not apply these, just 1.4.8-r1. Signed-off-by: Sam James <sam <AT> gentoo.org> .../files/1.4.8/0001-systemd-unit-sandbox.patch | 41 +++++++ .../0002-alsa-dont-fail-if-3-periods_min.patch | 42 ++++++++ .../files/1.4.8/0003-adapter-fix-Start.patch | 54 ++++++++++ .../1.4.8/0004-alsa-use-minimum-period-size.patch | 119 +++++++++++++++++++++ .../1.4.8/0005-avahi-fd-allocation-errors.patch | 45 ++++++++ ...ewire-1.4.8.ebuild => pipewire-1.4.8-r1.ebuild} | 0 media-video/pipewire/pipewire-1.4.8.ebuild | 6 +- 7 files changed, 304 insertions(+), 3 deletions(-) diff --git a/media-video/pipewire/files/1.4.8/0001-systemd-unit-sandbox.patch b/media-video/pipewire/files/1.4.8/0001-systemd-unit-sandbox.patch new file mode 100644 index 000000000000..8c7014f7e9f4 --- /dev/null +++ b/media-video/pipewire/files/1.4.8/0001-systemd-unit-sandbox.patch @@ -0,0 +1,41 @@ +https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/8f35e18d18b18b8db959793fe73fc594e5da8cd5 + +From 8f35e18d18b18b8db959793fe73fc594e5da8cd5 Mon Sep 17 00:00:00 2001 +From: Wim Taymans <[email protected]> +Date: Wed, 17 Sep 2025 10:21:10 +0200 +Subject: [PATCH] systemd: remove RestrictNamespaces from service file + +Wireplumber loads the libcamera nodes into the pipewire server. +We need to remove the RestrictNamespaces option from the service file +to allow libcamera to load sandboxed IPA modules. +--- + src/daemon/systemd/system/pipewire.service.in | 1 - + src/daemon/systemd/user/pipewire.service.in | 1 - + 2 files changed, 2 deletions(-) + +diff --git a/src/daemon/systemd/system/pipewire.service.in b/src/daemon/systemd/system/pipewire.service.in +index dc8db3f8f0..aeddea3008 100644 +--- a/src/daemon/systemd/system/pipewire.service.in ++++ b/src/daemon/systemd/system/pipewire.service.in +@@ -18,7 +18,6 @@ Requires=pipewire.socket + LockPersonality=yes + MemoryDenyWriteExecute=yes + NoNewPrivileges=yes +-RestrictNamespaces=yes + SystemCallArchitectures=native + SystemCallFilter=@system-service + Type=simple +diff --git a/src/daemon/systemd/user/pipewire.service.in b/src/daemon/systemd/user/pipewire.service.in +index 27818b4b94..c2621e421d 100644 +--- a/src/daemon/systemd/user/pipewire.service.in ++++ b/src/daemon/systemd/user/pipewire.service.in +@@ -20,7 +20,6 @@ ConditionUser=!root + LockPersonality=yes + MemoryDenyWriteExecute=yes + NoNewPrivileges=yes +-RestrictNamespaces=yes + SystemCallArchitectures=native + SystemCallFilter=@system-service mincore + Type=simple +-- +GitLab diff --git a/media-video/pipewire/files/1.4.8/0002-alsa-dont-fail-if-3-periods_min.patch b/media-video/pipewire/files/1.4.8/0002-alsa-dont-fail-if-3-periods_min.patch new file mode 100644 index 000000000000..43544962886e --- /dev/null +++ b/media-video/pipewire/files/1.4.8/0002-alsa-dont-fail-if-3-periods_min.patch @@ -0,0 +1,42 @@ +https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4912 +https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/dd3798487c2ffae9a6b294eb475c72fe1684d3ea + +From dd3798487c2ffae9a6b294eb475c72fe1684d3ea Mon Sep 17 00:00:00 2001 +From: Pauli Virtanen <[email protected]> +Date: Mon, 22 Sep 2025 20:27:19 +0300 +Subject: [PATCH] alsa: don't fail if 3 periods_min fails + +Some drivers (emu10k1) appear to not necessarily support more than 2 +periods. + +Don't fail start if snd_pcm_hw_params_set_periods_min() fails, then we +just set nearest possible periods and buffer sizes. +--- + spa/plugins/alsa/alsa-pcm.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c +index cea6d3e44d..509e187423 100644 +--- a/spa/plugins/alsa/alsa-pcm.c ++++ b/spa/plugins/alsa/alsa-pcm.c +@@ -2358,10 +2358,14 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ + snd_pcm_uframes_t period_size_max; + unsigned int periods_min = (periods == UINT_MAX) ? 3 : periods; + +- CHECK(snd_pcm_hw_params_set_periods_min(hndl, params, &periods_min, &dir), "set_periods_min"); +- CHECK(snd_pcm_hw_params_get_period_size_max(params, &period_size_max, &dir), "get_period_size_max"); +- if (period_size > period_size_max) +- period_size = SPA_MIN(period_size, flp2(period_size_max)); ++ err = snd_pcm_hw_params_set_periods_min(hndl, params, &periods_min, &dir); ++ if (!err) { ++ CHECK(snd_pcm_hw_params_get_period_size_max(params, &period_size_max, &dir), "get_period_size_max"); ++ if (period_size > period_size_max) ++ period_size = SPA_MIN(period_size, flp2(period_size_max)); ++ } else { ++ spa_log_debug(state->log, "set_periods_min: %s", snd_strerror(err)); ++ } + } + + CHECK(snd_pcm_hw_params_set_period_size_near(hndl, params, &period_size, &dir), "set_period_size_near"); +-- +GitLab diff --git a/media-video/pipewire/files/1.4.8/0003-adapter-fix-Start.patch b/media-video/pipewire/files/1.4.8/0003-adapter-fix-Start.patch new file mode 100644 index 000000000000..8eefaa8f5257 --- /dev/null +++ b/media-video/pipewire/files/1.4.8/0003-adapter-fix-Start.patch @@ -0,0 +1,54 @@ +https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/78937ee0ece9dc5f35c7bc6fa9fad3abe9b3eb9f + +From 78937ee0ece9dc5f35c7bc6fa9fad3abe9b3eb9f Mon Sep 17 00:00:00 2001 +From: Wim Taymans <[email protected]> +Date: Wed, 24 Sep 2025 12:36:13 +0200 +Subject: [PATCH] adapter: fix Start of adapter + +Commit cbbf37c3b8b6c77e111ab229c3315aadb9690bf9 changed the logic of the +Start command. Before this commit, when there was no converter, the +follower would always get the Start command. After the commit, the +follower would only get Start when previously Paused. + +This however breaks when we set a format or buffers on the follower +without a converter because those actions might change the state of the +follower to Paused implicitly. + +We should simply remove the started check here and always call Start on +the converter and follower, the implementations themselves will keep track +if anything needs to be done. + +Fixes #4911 +--- + spa/plugins/audioconvert/audioadapter.c | 2 -- + spa/plugins/videoconvert/videoadapter.c | 2 -- + 2 files changed, 4 deletions(-) + +diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c +index 2e42b6f432..b4535dd765 100644 +--- a/spa/plugins/audioconvert/audioadapter.c ++++ b/spa/plugins/audioconvert/audioadapter.c +@@ -1013,8 +1013,6 @@ static int impl_node_send_command(void *object, const struct spa_command *comman + switch (SPA_NODE_COMMAND_ID(command)) { + case SPA_NODE_COMMAND_Start: + spa_log_debug(this->log, "%p: starting %d", this, this->started); +- if (this->started) +- return 0; + if ((res = negotiate_format(this)) < 0) + return res; + this->ready = true; +diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c +index 5b101ff3d9..c901b99e6c 100644 +--- a/spa/plugins/videoconvert/videoadapter.c ++++ b/spa/plugins/videoconvert/videoadapter.c +@@ -980,8 +980,6 @@ static int impl_node_send_command(void *object, const struct spa_command *comman + switch (SPA_NODE_COMMAND_ID(command)) { + case SPA_NODE_COMMAND_Start: + spa_log_debug(this->log, "%p: starting %d", this, this->started); +- if (this->started) +- return 0; + if ((res = negotiate_format(this)) < 0) + return res; + this->ready = true; +-- +GitLab diff --git a/media-video/pipewire/files/1.4.8/0004-alsa-use-minimum-period-size.patch b/media-video/pipewire/files/1.4.8/0004-alsa-use-minimum-period-size.patch new file mode 100644 index 000000000000..12f1dddb574b --- /dev/null +++ b/media-video/pipewire/files/1.4.8/0004-alsa-use-minimum-period-size.patch @@ -0,0 +1,119 @@ +https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/ba7790123c345002b08712babc7bf252f39e4485 + +From ba7790123c345002b08712babc7bf252f39e4485 Mon Sep 17 00:00:00 2001 +From: Peter Ujfalusi <[email protected]> +Date: Tue, 23 Sep 2025 13:20:12 +0300 +Subject: [PATCH] alsa: Use the minimum period size as headroom for SOF cards + +Configure the headroom to be equal of the minimum allowed period size for +the configuration. + +This is desirable when the ALSA driver's hw_ptr is 'jumpy' due to +underplaying hardware architecture, like SOF. +In case of SOF the DSP firmware will burst read at stream start to fill +it's host facing buffer and later settles to a constant pace. The minimal +period size is constrained by the driver to cover the initial burst and +settling time of the hw_ptr. + +Guard this mode of working with a new boolean flag, which is only enabled +for SOF cards, kept it disabled for other cards to avoid any unforeseen +side effects. + +Even if the use-period-size-min-as-headroom is set to true, the manual +headroom configuration will take precedence to allow experimentation. + +Link: https://github.com/thesofproject/linux/issues/5284 +Link: https://github.com/thesofproject/sof/issues/9695#issuecomment-2569033847 +Link: https://github.com/thesofproject/sof/issues/10172 +Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4489 +Signed-off-by: Peter Ujfalusi <[email protected]> +--- + spa/plugins/alsa/alsa-pcm.c | 26 ++++++++++++++++++++++---- + spa/plugins/alsa/alsa-pcm.h | 2 ++ + 2 files changed, 24 insertions(+), 4 deletions(-) + +diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c +index 509e187423..1bb31e7a32 100644 +--- a/spa/plugins/alsa/alsa-pcm.c ++++ b/spa/plugins/alsa/alsa-pcm.c +@@ -969,6 +969,13 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) + if ((str = spa_dict_lookup(info, "device.profile.pro")) != NULL) + state->is_pro = spa_atob(str); + ++ if (info && spa_strstartswith(spa_dict_lookup(info, SPA_KEY_API_ALSA_CARD_NAME), "sof-") && ++ state->stream == SND_PCM_STREAM_PLAYBACK) { ++ state->use_period_size_min_as_headroom = true; ++ spa_log_info(state->log, ++ "ALSA SOF driver detected: default api.alsa.use-period-size-min-as-headroom=true"); ++ } ++ + state->multi_rate = true; + state->htimestamp = false; + state->htimestamp_max_errors = MAX_HTIMESTAMP_ERROR; +@@ -2032,7 +2039,12 @@ static void recalc_headroom(struct state *state) + if (state->position != NULL) + rate = state->position->clock.target_rate.denom; + +- state->headroom = state->default_headroom; ++ if (state->use_period_size_min_as_headroom) ++ state->headroom = state->default_headroom ? ++ state->default_headroom : state->period_size_min; ++ else ++ state->headroom = state->default_headroom; ++ + if (!state->disable_tsched || state->resample) { + /* When using timers, we might miss the pointer update for batch + * devices so add some extra headroom. With IRQ, we know the pointers +@@ -2349,6 +2361,12 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ + periods = UINT_MAX; + } + ++ /* Query the minimum period size for this configuration ++ * This information is used as headroom if use_period_size_min_as_headroom is ++ * set and default_headroom is 0 (not forced by user) ++ */ ++ CHECK(snd_pcm_hw_params_get_period_size_min(params, &state->period_size_min, &dir), "snd_pcm_hw_params_get_period_size_min"); ++ + if (state->default_period_size == 0) { + /* Some devices (FireWire) don't produce audio if period number is too + * small, so force a minimum. This will restrict possible period sizes if +@@ -2408,14 +2426,14 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ + recalc_headroom(state); + + spa_log_info(state->log, "%s: format:%s access:%s-%s rate:%d channels:%d " +- "buffer frames %lu, period frames %lu, periods %u, frame_size %zd " ++ "buffer frames %lu, period frames %lu (min:%lu), periods %u, frame_size %zd " + "headroom %u start-delay:%u batch:%u tsched:%u resample:%u", + state->name, snd_pcm_format_name(state->format), + state->use_mmap ? "mmap" : "rw", + planar ? "planar" : "interleaved", + state->rate, state->channels, state->buffer_frames, state->period_frames, +- periods, state->frame_size, state->headroom, state->start_delay, +- state->is_batch, !state->disable_tsched, state->resample); ++ state->period_size_min, periods, state->frame_size, state->headroom, ++ state->start_delay, state->is_batch, !state->disable_tsched, state->resample); + + /* write the parameters to device */ + CHECK(snd_pcm_hw_params(hndl, params), "set_hw_params"); +diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h +index 576144bfeb..6f2876fbc3 100644 +--- a/spa/plugins/alsa/alsa-pcm.h ++++ b/spa/plugins/alsa/alsa-pcm.h +@@ -203,6 +203,7 @@ struct state { + int n_fds; + uint32_t threshold; + uint32_t last_threshold; ++ snd_pcm_uframes_t period_size_min; + uint32_t headroom; + uint32_t start_delay; + uint32_t min_delay; +@@ -233,6 +234,7 @@ struct state { + unsigned int linked:1; + unsigned int is_batch:1; + unsigned int force_rate:1; ++ unsigned int use_period_size_min_as_headroom:1; + + uint64_t iec958_codecs; + +-- +GitLab diff --git a/media-video/pipewire/files/1.4.8/0005-avahi-fd-allocation-errors.patch b/media-video/pipewire/files/1.4.8/0005-avahi-fd-allocation-errors.patch new file mode 100644 index 000000000000..5167061a91ef --- /dev/null +++ b/media-video/pipewire/files/1.4.8/0005-avahi-fd-allocation-errors.patch @@ -0,0 +1,45 @@ +https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/636cbae9b6cebc4ba55903e2a686f4c4a2bd4193 + +From 636cbae9b6cebc4ba55903e2a686f4c4a2bd4193 Mon Sep 17 00:00:00 2001 +From: Wim Taymans <[email protected]> +Date: Fri, 26 Sep 2025 10:52:40 +0200 +Subject: [PATCH] avahi: handle fd allocation errors + +When we fail to allocate an io source or a timerfd, return NULL instead +of crashing later on. + +See #4913 +--- + src/modules/module-zeroconf-discover/avahi-poll.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/modules/module-zeroconf-discover/avahi-poll.c b/src/modules/module-zeroconf-discover/avahi-poll.c +index ab54888f65..65b64736af 100644 +--- a/src/modules/module-zeroconf-discover/avahi-poll.c ++++ b/src/modules/module-zeroconf-discover/avahi-poll.c +@@ -72,7 +72,10 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event + w->userdata = userdata; + w->source = pw_loop_add_io(impl->loop, fd, to_pw_events(event), + false, watch_callback, w); +- ++ if (w->source == NULL) { ++ free(w); ++ return NULL; ++ } + return w; + } + +@@ -117,7 +120,10 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv, + w->callback = callback; + w->userdata = userdata; + w->source = pw_loop_add_timer(impl->loop, timeout_callback, w); +- ++ if (w->source == NULL) { ++ free(w); ++ return NULL; ++ } + if (tv != NULL) { + value.tv_sec = tv->tv_sec; + value.tv_nsec = tv->tv_usec * 1000UL; +-- +GitLab diff --git a/media-video/pipewire/pipewire-1.4.8.ebuild b/media-video/pipewire/pipewire-1.4.8-r1.ebuild similarity index 100% copy from media-video/pipewire/pipewire-1.4.8.ebuild copy to media-video/pipewire/pipewire-1.4.8-r1.ebuild diff --git a/media-video/pipewire/pipewire-1.4.8.ebuild b/media-video/pipewire/pipewire-1.4.8.ebuild index 69832cf73fcc..6ba8b6237d9b 100644 --- a/media-video/pipewire/pipewire-1.4.8.ebuild +++ b/media-video/pipewire/pipewire-1.4.8.ebuild @@ -200,9 +200,9 @@ src_prepare() { default # Used for upstream backports - if [[ ${PV} != *9999 && -d "${FILESDIR}"/${PV} ]] ; then - eapply "${FILESDIR}"/${PV} - fi + #if [[ ${PV} != *9999 && -d "${FILESDIR}"/${PV} ]] ; then + # eapply "${FILESDIR}"/${PV} + #fi } multilib_src_configure() {
