Add patch to fix speaker-test.

Add patch to fix noise in resampler.
This commit is contained in:
Wim Taymans 2022-07-04 12:30:49 +02:00
parent b8b36c5d78
commit 1821ed0e59
3 changed files with 93 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 927aec728e9509ed3018ca967a593fc17d4af7c7 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
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

View File

@ -0,0 +1,44 @@
From c380d27ce2e7a01dcbe8e398886375ad362d4bf1 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
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

View File

@ -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 <wtaymans@redhat.com> - 0.3.53-3
- Add patch to fix speaker-test.
- Add patch to fix noise in resampler.
* Fri Jul 1 2022 Wim Taymans <wtaymans@redhat.com> - 0.3.53-2
- Add patch to avoid crash in audioconvert (mpv)