commit:     01e20d6c31ad656256ae2dc6fa4b2e49fe4d30e7
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 18 22:37:23 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jan 18 22:38:57 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=01e20d6c

media-video/pipewire: backport misc. patches for 0.3.64

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...pa-Fix-audioconvert-overflow-when-scaling.patch | 65 ++++++++++++++++++++++
 ...ter-chain-fix-AVX-dsp_sum-index-increment.patch | 22 ++++++++
 ...on-t-remove-deprecated-symbols-by-default.patch | 61 ++++++++++++++++++++
 ...ewire-9999.ebuild => pipewire-0.3.64-r1.ebuild} |  3 +
 media-video/pipewire/pipewire-9999.ebuild          |  3 +
 5 files changed, 154 insertions(+)

diff --git 
a/media-video/pipewire/files/0.3.64/0001-spa-Fix-audioconvert-overflow-when-scaling.patch
 
b/media-video/pipewire/files/0.3.64/0001-spa-Fix-audioconvert-overflow-when-scaling.patch
new file mode 100644
index 000000000000..e24b8153ef6d
--- /dev/null
+++ 
b/media-video/pipewire/files/0.3.64/0001-spa-Fix-audioconvert-overflow-when-scaling.patch
@@ -0,0 +1,65 @@
+https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/1d9640af5a7906620f214aa0a39c63128c8506a6.
+
+From 1d9640af5a7906620f214aa0a39c63128c8506a6 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <[email protected]>
+Date: Mon, 16 Jan 2023 18:28:31 +0100
+Subject: [PATCH] spa: Fix audioconvert overflow when scaling
+
+Add SPA_SCALE32_UP that scales a uint32 without overflow.
+Use this for scaling the threshold in ALSA.
+Fix the scaling in audioconvert of the buffer size, the scaling was
+wrong and it was also causing an overflow resulting in choppy sound in
+some cases.
+
+See #2680
+--- a/spa/include/spa/utils/defs.h
++++ b/spa/include/spa/utils/defs.h
+@@ -274,6 +274,14 @@ struct spa_fraction {
+ #define SPA_ROUND_DOWN_N(num,align)   ((num) & ~SPA_ROUND_MASK(num, align))
+ #define SPA_ROUND_UP_N(num,align)     ((((num)-1) | SPA_ROUND_MASK(num, 
align))+1)
+ 
++#define SPA_SCALE32_UP(val,num,denom)                         \
++({                                                            \
++      uint64_t _val = (val);                                  \
++      uint64_t _denom = (denom);                              \
++      (uint32_t)(((_val) * (num) + (_denom)-1) / (_denom));   \
++})
++
++
+ #define SPA_PTR_ALIGNMENT(p,align)    ((intptr_t)(p) & ((align)-1))
+ #define SPA_IS_ALIGNED(p,align)               (SPA_PTR_ALIGNMENT(p,align) == 
0)
+ #define SPA_PTR_ALIGN(p,align,type)   ((type*)SPA_ROUND_UP_N((intptr_t)(p), 
(intptr_t)(align)))
+--- a/spa/plugins/alsa/alsa-pcm.c
++++ b/spa/plugins/alsa/alsa-pcm.c
+@@ -1999,7 +1999,7 @@ static inline void check_position_config(struct state 
*state)
+           (state->rate_denom != state->position->clock.rate.denom))) {
+               state->duration = state->position->clock.duration;
+               state->rate_denom = state->position->clock.rate.denom;
+-              state->threshold = (state->duration * state->rate + 
state->rate_denom-1) / state->rate_denom;
++              state->threshold = SPA_SCALE32_UP(state->duration, state->rate, 
state->rate_denom);
+               state->max_error = SPA_MAX(256.0f, state->threshold / 2.0f);
+               state->resample = ((uint32_t)state->rate != state->rate_denom) 
|| state->matching;
+               state->alsa_sync = true;
+@@ -2569,7 +2569,7 @@ int spa_alsa_start(struct state *state)
+       setup_matching(state);
+ 
+       spa_dll_init(&state->dll);
+-      state->threshold = (state->duration * state->rate + 
state->rate_denom-1) / state->rate_denom;
++      state->threshold = SPA_SCALE32_UP(state->duration, state->rate, 
state->rate_denom);
+       state->last_threshold = state->threshold;
+       state->max_error = SPA_MAX(256.0f, state->threshold / 2.0f);
+ 
+--- a/spa/plugins/audioconvert/audioconvert.c
++++ b/spa/plugins/audioconvert/audioconvert.c
+@@ -1755,7 +1755,7 @@ impl_node_port_enum_params(void *object, int seq,
+                       size = this->quantum_limit * 2;
+                       /*  scale the buffer size when we can. */
+                       if (irate != 0 && orate != 0)
+-                              size = size * (irate + orate - 1) / orate;
++                              size = SPA_SCALE32_UP(size, irate, orate);
+               }
+ 
+               param = spa_pod_builder_add_object(&b,
+-- 
+2.39.1
+

diff --git 
a/media-video/pipewire/files/0.3.64/0002-filter-chain-fix-AVX-dsp_sum-index-increment.patch
 
b/media-video/pipewire/files/0.3.64/0002-filter-chain-fix-AVX-dsp_sum-index-increment.patch
new file mode 100644
index 000000000000..f33a83ab7a10
--- /dev/null
+++ 
b/media-video/pipewire/files/0.3.64/0002-filter-chain-fix-AVX-dsp_sum-index-increment.patch
@@ -0,0 +1,22 @@
+https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/ccedf1722ae44c97ec0d058b349494c67a0b56dc
+
+From ccedf1722ae44c97ec0d058b349494c67a0b56dc Mon Sep 17 00:00:00 2001
+From: Wim Taymans <[email protected]>
+Date: Tue, 17 Jan 2023 09:24:00 +0100
+Subject: [PATCH] filter-chain: fix AVX dsp_sum index increment
+
+Fixes #2965
+--- a/src/modules/module-filter-chain/dsp-ops-avx.c
++++ b/src/modules/module-filter-chain/dsp-ops-avx.c
+@@ -59,7 +59,7 @@ void dsp_sum_avx(struct dsp_ops *ops, float *r, const float 
*a, const float *b,
+                       _mm256_store_ps(&r[n+24], in[3]);
+               }
+       } else {
+-              for (n = 0; n < unrolled; n += 16) {
++              for (n = 0; n < unrolled; n += 32) {
+                       in[0] = _mm256_loadu_ps(&a[n+ 0]);
+                       in[1] = _mm256_loadu_ps(&a[n+ 8]);
+                       in[2] = _mm256_loadu_ps(&a[n+16]);
+-- 
+2.39.1
+

diff --git 
a/media-video/pipewire/files/0.3.64/0003-keys-don-t-remove-deprecated-symbols-by-default.patch
 
b/media-video/pipewire/files/0.3.64/0003-keys-don-t-remove-deprecated-symbols-by-default.patch
new file mode 100644
index 000000000000..fe022959a913
--- /dev/null
+++ 
b/media-video/pipewire/files/0.3.64/0003-keys-don-t-remove-deprecated-symbols-by-default.patch
@@ -0,0 +1,61 @@
+https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/a979c0f43078cbfefa2ba614ee078579042d2de2
+
+From a979c0f43078cbfefa2ba614ee078579042d2de2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <[email protected]>
+Date: Tue, 17 Jan 2023 11:58:04 +0100
+Subject: [PATCH] keys: don't remove deprecated symbols by default
+
+Add a new macro to mark deprecated keys. The macro will emit a warning
+about the symbol being deprecated.
+PW_ENABLE_DEPRECATED will suppress the deprecation warning.
+Add PW_REMOVE_DEPRECATED to completely remove the deprecated symbols.
+
+Fixes #2952
+--- a/src/pipewire/keys.h
++++ b/src/pipewire/keys.h
+@@ -29,6 +29,7 @@
+ extern "C" {
+ #endif
+ 
++#include <pipewire/utils.h>
+ /**
+  * \defgroup pw_keys Key Names
+  *
+@@ -337,14 +338,14 @@ extern "C" {
+ #define PW_KEY_VIDEO_FORMAT           "video.format"          /**< a video 
format */
+ #define PW_KEY_VIDEO_SIZE             "video.size"            /**< a video 
size as "<width>x<height" */
+ 
+-#ifdef PW_ENABLE_DEPRECATED
+-#define PW_KEY_PRIORITY_MASTER                "priority.master"       /**< 
deprecated */
+-#define PW_KEY_NODE_TARGET            "node.target"           /**< deprecated 
since 0.3.64, use target.object. */
+-#endif /* PW_ENABLE_DEPRECATED */
+-
+ #define PW_KEY_TARGET_OBJECT          "target.object"         /**< a target 
object to link to. This can be
+                                                                 * and object 
name or object.serial */
+ 
++#ifndef PW_REMOVE_DEPRECATED
++#define PW_KEY_PRIORITY_MASTER                
PW_DEPRECATED("priority.master")        /**< deprecated, use priority.driver */
++#define PW_KEY_NODE_TARGET            PW_DEPRECATED("node.target")            
/**< deprecated since 0.3.64, use target.object. */
++#endif /* PW_REMOVE_DEPRECATED */
++
+ /** \}
+  */
+ 
+--- a/src/pipewire/utils.h
++++ b/src/pipewire/utils.h
+@@ -94,6 +94,12 @@ ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int 
flags);
+ 
+ void* pw_reallocarray(void *ptr, size_t nmemb, size_t size);
+ 
++#ifdef PW_ENABLE_DEPRECATED
++#define PW_DEPRECATED(v)        (v)
++#else
++#define PW_DEPRECATED(v)      ({ __typeof__(v) _v SPA_DEPRECATED = (v); 
(void)_v; (v); })
++#endif /* PW_ENABLE_DEPRECATED */
++
+ /**
+  * \}
+  */
+-- 
+2.39.1
+

diff --git a/media-video/pipewire/pipewire-9999.ebuild 
b/media-video/pipewire/pipewire-0.3.64-r1.ebuild
similarity index 99%
copy from media-video/pipewire/pipewire-9999.ebuild
copy to media-video/pipewire/pipewire-0.3.64-r1.ebuild
index 39cb357fe7da..67d0679def54 100644
--- a/media-video/pipewire/pipewire-9999.ebuild
+++ b/media-video/pipewire/pipewire-0.3.64-r1.ebuild
@@ -166,6 +166,9 @@ python_check_deps() {
 src_prepare() {
        default
 
+       # Used for upstream backports
+       [[ -d "${FILESDIR}"/${PV} ]] && eapply "${FILESDIR}"/${PV}
+
        einfo "Generating ${limitsdfile}"
        cat > ${limitsdfile} <<- EOF || die
                # Start of ${limitsdfile} from ${P}

diff --git a/media-video/pipewire/pipewire-9999.ebuild 
b/media-video/pipewire/pipewire-9999.ebuild
index 39cb357fe7da..67d0679def54 100644
--- a/media-video/pipewire/pipewire-9999.ebuild
+++ b/media-video/pipewire/pipewire-9999.ebuild
@@ -166,6 +166,9 @@ python_check_deps() {
 src_prepare() {
        default
 
+       # Used for upstream backports
+       [[ -d "${FILESDIR}"/${PV} ]] && eapply "${FILESDIR}"/${PV}
+
        einfo "Generating ${limitsdfile}"
        cat > ${limitsdfile} <<- EOF || die
                # Start of ${limitsdfile} from ${P}

Reply via email to