From 1821ed0e591ea4337a151cade40646a679d8a385 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 4 Jul 2022 12:30:49 +0200 Subject: [PATCH] Add patch to fix speaker-test. Add patch to fix noise in resampler. --- 0001-audioconvert-fix-draining.patch | 42 ++++++++++++++++++ ...vert-handle-NAN-from-window-function.patch | 44 +++++++++++++++++++ pipewire.spec | 8 +++- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 0001-audioconvert-fix-draining.patch create mode 100644 0002-audioconvert-handle-NAN-from-window-function.patch diff --git a/0001-audioconvert-fix-draining.patch b/0001-audioconvert-fix-draining.patch new file mode 100644 index 0000000..064d291 --- /dev/null +++ b/0001-audioconvert-fix-draining.patch @@ -0,0 +1,42 @@ +From 927aec728e9509ed3018ca967a593fc17d4af7c7 Mon Sep 17 00:00:00 2001 +From: Wim Taymans +Date: Fri, 1 Jul 2022 21:49:13 +0200 +Subject: [PATCH 1/2] audioconvert: fix draining + +When we get something else that a drain status as input, bring us back +to the non-drained state. + +When we are draining, don't remove the drained flag on the input +io status. This needs to be cleared by the host when the draining is +finished. + +Fixes speaker-test +--- + spa/plugins/audioconvert/audioconvert.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c +index 8aaab28db..b7e2a873e 100644 +--- a/spa/plugins/audioconvert/audioconvert.c ++++ b/spa/plugins/audioconvert/audioconvert.c +@@ -2254,6 +2254,7 @@ static int impl_node_process(void *object) + spa_log_trace_fp(this->log, "%p: empty input port %d %p %d %d %d", + this, port->id, io, io->status, io->buffer_id, + port->n_buffers); ++ this->drained = false; + } + buf = NULL; + } else if (SPA_UNLIKELY(io->buffer_id >= port->n_buffers)) { +@@ -2533,7 +2534,8 @@ static int impl_node_process(void *object) + if (SPA_UNLIKELY((io = port->io) == NULL)) + continue; + spa_log_trace_fp(this->log, "return: input %d %d", port->id, io->buffer_id); +- io->status = SPA_STATUS_NEED_DATA; ++ if (!draining) ++ io->status = SPA_STATUS_NEED_DATA; + } + this->in_offset = 0; + max_in = 0; +-- +2.36.1 + diff --git a/0002-audioconvert-handle-NAN-from-window-function.patch b/0002-audioconvert-handle-NAN-from-window-function.patch new file mode 100644 index 0000000..fd22e32 --- /dev/null +++ b/0002-audioconvert-handle-NAN-from-window-function.patch @@ -0,0 +1,44 @@ +From c380d27ce2e7a01dcbe8e398886375ad362d4bf1 Mon Sep 17 00:00:00 2001 +From: Wim Taymans +Date: Sun, 3 Jul 2022 20:37:48 +0200 +Subject: [PATCH 2/2] audioconvert: handle NAN from window function + +The window function can generate NAN, convert those to 0.0. + +Fixes #2491 +--- + spa/plugins/audioconvert/resample-native.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/spa/plugins/audioconvert/resample-native.c b/spa/plugins/audioconvert/resample-native.c +index e250ff10a..0b06d4960 100644 +--- a/spa/plugins/audioconvert/resample-native.c ++++ b/spa/plugins/audioconvert/resample-native.c +@@ -61,18 +61,20 @@ static inline double sinc(double x) + #if 0 + static inline double window_blackman(double x, double n_taps) + { +- double alpha = 0.232; ++ double alpha = 0.232, r; + x = 2.0 * M_PI * x / n_taps; +- return (1.0 - alpha) / 2.0 + (1.0 / 2.0) * cos(x) + ++ r = (1.0 - alpha) / 2.0 + (1.0 / 2.0) * cos(x) + + (alpha / 2.0) * cos(2 * x); ++ return r; + } + #else + static inline double window_cosh(double x, double n_taps) + { +- double R = 95.0; ++ double R = 95.0, r; + double A = -325.1E-6 * (R * R) + 0.1677 * R - 3.149; + x = 2.0 * M_PI * x / n_taps; +- return cosh(A * sqrt(1 - pow(x / M_PI, 2))) / cosh(A); ++ r = cosh(A * sqrt(1 - pow(x / M_PI, 2))) / cosh(A); ++ return isnan(r) ? 0.0 : r; + } + #endif + +-- +2.36.1 + diff --git a/pipewire.spec b/pipewire.spec index 40de67b..4352256 100644 --- a/pipewire.spec +++ b/pipewire.spec @@ -9,7 +9,7 @@ %global ms_version 0.4.1 # For rpmdev-bumpspec and releng automation -%global baserelease 2 +%global baserelease 3 #global snapdate 20210107 #global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb @@ -81,6 +81,8 @@ Source1: https://gitlab.freedesktop.org/pipewire/media-session/-/archive/ ## upstream patches Patch0001: 0001-audioconvert-ensure-temp-buffers-are-large-enough.patch +Patch0002: 0001-audioconvert-fix-draining.patch +Patch0003: 0002-audioconvert-handle-NAN-from-window-function.patch ## upstreamable patches @@ -618,6 +620,10 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || : %endif %changelog +* Mon Jul 4 2022 Wim Taymans - 0.3.53-3 +- Add patch to fix speaker-test. +- Add patch to fix noise in resampler. + * Fri Jul 1 2022 Wim Taymans - 0.3.53-2 - Add patch to avoid crash in audioconvert (mpv)