commit: ddf7f65270b4cfb1117bdf1bde0e611b7e1417d6 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Thu Jan 16 18:40:52 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Thu Jan 16 18:40:52 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddf7f652
media-video/pipewire: backport upstream fixes to 1.2.7 >From the 1.2 branch. Closes: https://bugs.gentoo.org/948169 Signed-off-by: Sam James <sam <AT> gentoo.org> ...sa-Fix-key-name-suggestion-in-log-message.patch | 28 ++ ...pa-alsa-Don-t-assume-all-PCMs-have-a-card.patch | 128 +++++++++ ...st-mark-the-pipewiresink-as-EARLY_PROCESS.patch | 29 ++ .../0004-gst-add-rate-control-to-the-sink.patch | 234 ++++++++++++++++ .../1.2.7/0005-gst-add-slave-method-property.patch | 259 +++++++++++++++++ .../1.2.7/0006-spa-fix-some-param-type-info.patch | 51 ++++ .../0007-filter-chain-handle-0-length-IR.patch | 305 +++++++++++++++++++++ ...0008-spa-initialize-all-fields-explicitly.patch | 47 ++++ ...ewire-1.2.7.ebuild => pipewire-1.2.7-r1.ebuild} | 2 +- media-video/pipewire/pipewire-1.2.7.ebuild | 2 +- 10 files changed, 1083 insertions(+), 2 deletions(-) diff --git a/media-video/pipewire/files/1.2.7/0001-spa-alsa-Fix-key-name-suggestion-in-log-message.patch b/media-video/pipewire/files/1.2.7/0001-spa-alsa-Fix-key-name-suggestion-in-log-message.patch new file mode 100644 index 000000000000..a9348553e15b --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0001-spa-alsa-Fix-key-name-suggestion-in-log-message.patch @@ -0,0 +1,28 @@ +From 1993383ddf67e296334c7916d6afc699ee6300c7 Mon Sep 17 00:00:00 2001 +Message-ID: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Arun Raghavan <[email protected]> +Date: Fri, 29 Nov 2024 10:54:18 -0500 +Subject: [PATCH 1/8] spa: alsa: Fix key name suggestion in log message + +We use api.alsa.pcm.card to look up the PCM's card if we don't know it +by other means. +--- + spa/plugins/alsa/alsa-pcm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c +index b07897935..9244b66aa 100644 +--- a/spa/plugins/alsa/alsa-pcm.c ++++ b/spa/plugins/alsa/alsa-pcm.c +@@ -939,7 +939,7 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) + sscanf(state->props.device, "%*[^:]:%u", &state->card_index); + if (state->card_index == SPA_ID_INVALID) { + spa_log_error(state->log, "Could not determine card index, maybe set %s", +- SPA_KEY_API_ALSA_CARD); ++ SPA_KEY_API_ALSA_PCM_CARD); + return -EINVAL; + } + } +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0002-spa-alsa-Don-t-assume-all-PCMs-have-a-card.patch b/media-video/pipewire/files/1.2.7/0002-spa-alsa-Don-t-assume-all-PCMs-have-a-card.patch new file mode 100644 index 000000000000..efb13f667b9a --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0002-spa-alsa-Don-t-assume-all-PCMs-have-a-card.patch @@ -0,0 +1,128 @@ +From a6019e6dd73e686c69db5967fc3e852a8fe43ecb Mon Sep 17 00:00:00 2001 +Message-ID: <a6019e6dd73e686c69db5967fc3e852a8fe43ecb.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Arun Raghavan <[email protected]> +Date: Fri, 29 Nov 2024 10:42:58 -0500 +Subject: [PATCH 2/8] spa: alsa: Don't assume all PCMs have a card + +dmix/dsnoop devices, for example, don't have an associated card, so all +the card-related checks don't make sense. Let's explicitly deal with +this case. + +Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4432 +--- + spa/plugins/alsa/alsa-pcm.c | 31 +++++++++++++++++-------------- + 1 file changed, 17 insertions(+), 14 deletions(-) + +diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c +index 9244b66aa..b8728bfe1 100644 +--- a/spa/plugins/alsa/alsa-pcm.c ++++ b/spa/plugins/alsa/alsa-pcm.c +@@ -40,6 +40,9 @@ static struct card *ensure_card(uint32_t index, bool ucm) + const char *alibpref = NULL; + int err; + ++ if (index == SPA_ID_INVALID) ++ return NULL; ++ + if ((c = find_card(index)) != NULL) + return c; + +@@ -78,6 +81,9 @@ error: + + static void release_card(struct card *c) + { ++ if (!c) ++ return; ++ + spa_assert(c->ref > 0); + + if (--c->ref > 0) +@@ -657,7 +663,7 @@ static void silence_error_handler(const char *file, int line, + static void fill_device_name(struct state *state, const char *params, char device_name[], size_t len) + { + spa_scnprintf(device_name, len, "%s%s%s", +- state->card->ucm_prefix ? state->card->ucm_prefix : "", ++ state->card && state->card->ucm_prefix ? state->card->ucm_prefix : "", + state->props.device, params ? params : ""); + } + +@@ -938,13 +944,12 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) + /* If we don't have a card index, see if we have a *:<idx> string */ + sscanf(state->props.device, "%*[^:]:%u", &state->card_index); + if (state->card_index == SPA_ID_INVALID) { +- spa_log_error(state->log, "Could not determine card index, maybe set %s", +- SPA_KEY_API_ALSA_PCM_CARD); +- return -EINVAL; ++ spa_log_info(state->log, "Could not determine card index. %s and/or clock.name " ++ "may need to be configured manually", SPA_KEY_API_ALSA_PCM_CARD); + } + } + +- if (state->clock_name[0] == '\0') ++ if (state->clock_name[0] == '\0' && state->card_index != SPA_ID_INVALID) + snprintf(state->clock_name, sizeof(state->clock_name), + "api.alsa.%s-%u", + state->stream == SND_PCM_STREAM_PLAYBACK ? "p" : "c", +@@ -957,10 +962,7 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info) + } + + state->card = ensure_card(state->card_index, state->open_ucm); +- if (state->card == NULL) { +- spa_log_error(state->log, "can't create card %u", state->card_index); +- return -errno; +- } ++ + state->log_file = fopencookie(state, "w", io_funcs); + if (state->log_file == NULL) { + spa_log_error(state->log, "can't create log file"); +@@ -1203,7 +1205,7 @@ int spa_alsa_close(struct state *state) + else + state->n_fds = 0; + +- if (state->have_format) ++ if (state->have_format && state->card) + state->card->format_ref--; + + state->have_format = false; +@@ -1423,7 +1425,7 @@ static int add_rate(struct state *state, uint32_t scale, uint32_t interleave, bo + if (max < min) + return 0; + +- if (!state->multi_rate && state->card->format_ref > 0) ++ if (!state->multi_rate && state->card && state->card->format_ref > 0) + rate = state->card->rate; + else + rate = state->default_rate; +@@ -1439,8 +1441,8 @@ static int add_rate(struct state *state, uint32_t scale, uint32_t interleave, bo + + rate = SPA_CLAMP(rate, min, max); + +- spa_log_debug(state->log, "rate:%u multi:%d card:%d def:%d", +- rate, state->multi_rate, state->card->rate, state->default_rate); ++ spa_log_debug(state->log, "rate:%u multi:%d card:%u def:%d", ++ rate, state->multi_rate, state->card ? state->card->rate : 0, state->default_rate); + + spa_pod_builder_prop(b, SPA_FORMAT_AUDIO_rate, 0); + +@@ -2172,6 +2174,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ + } + + if (!state->multi_rate && ++ state->card && + state->card->format_ref > 0 && + state->card->rate != rrate) { + spa_log_error(state->log, "%p: card already opened at rate:%i", +@@ -2217,7 +2220,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ + state->driver_rate.denom = 0; + + state->have_format = true; +- if (state->card->format_ref++ == 0) ++ if (state->card && state->card->format_ref++ == 0) + state->card->rate = rrate; + + dir = 0; +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0003-gst-mark-the-pipewiresink-as-EARLY_PROCESS.patch b/media-video/pipewire/files/1.2.7/0003-gst-mark-the-pipewiresink-as-EARLY_PROCESS.patch new file mode 100644 index 000000000000..54f020f9379e --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0003-gst-mark-the-pipewiresink-as-EARLY_PROCESS.patch @@ -0,0 +1,29 @@ +From 938283aee4a1c120bf1c9285090ea196a5b5c89b Mon Sep 17 00:00:00 2001 +Message-ID: <938283aee4a1c120bf1c9285090ea196a5b5c89b.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Tue, 26 Nov 2024 16:57:14 +0100 +Subject: [PATCH 3/8] gst: mark the pipewiresink as EARLY_PROCESS + +We want to receive process callbacks as soon as a buffer is ready for +reuse because we dequeue it for use in our buffer pool. +--- + src/gst/gstpipewiresink.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c +index b39a335d8..d79ceaa66 100644 +--- a/src/gst/gstpipewiresink.c ++++ b/src/gst/gstpipewiresink.c +@@ -633,6 +633,7 @@ gst_pipewire_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) + char buf[64]; + + flags = PW_STREAM_FLAG_ASYNC; ++ flags |= PW_STREAM_FLAG_EARLY_PROCESS; + if (pwsink->mode != GST_PIPEWIRE_SINK_MODE_PROVIDE) + flags |= PW_STREAM_FLAG_AUTOCONNECT; + else +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0004-gst-add-rate-control-to-the-sink.patch b/media-video/pipewire/files/1.2.7/0004-gst-add-rate-control-to-the-sink.patch new file mode 100644 index 000000000000..1fdd40244948 --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0004-gst-add-rate-control-to-the-sink.patch @@ -0,0 +1,234 @@ +From 1e2b7f7c00fbded9e9ebb83b10ce302155ba444f Mon Sep 17 00:00:00 2001 +Message-ID: <1e2b7f7c00fbded9e9ebb83b10ce302155ba444f.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Tue, 26 Nov 2024 17:45:41 +0100 +Subject: [PATCH 4/8] gst: add rate control to the sink + +Track the elapsed time between buffers and try to keep the buffer fill +level constant by changing the rate of the stream. + +See #4374 +--- + src/gst/gstpipewiresink.c | 76 ++++++++++++++++++++++++++++++++++--- + src/gst/gstpipewiresink.h | 4 ++ + src/gst/gstpipewirestream.c | 1 + + src/gst/gstpipewirestream.h | 8 ++++ + src/gst/meson.build | 2 +- + 5 files changed, 84 insertions(+), 7 deletions(-) + +diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c +index d79ceaa66..33f2322e9 100644 +--- a/src/gst/gstpipewiresink.c ++++ b/src/gst/gstpipewiresink.c +@@ -26,6 +26,7 @@ + + #include <spa/pod/builder.h> + #include <spa/utils/result.h> ++#include <spa/utils/dll.h> + + #include <gst/video/video.h> + +@@ -481,14 +482,13 @@ static void + do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer) + { + GstPipeWirePoolData *data; ++ GstPipeWireStream *stream = pwsink->stream; + gboolean res; + guint i; + struct spa_buffer *b; + + data = gst_pipewire_pool_get_data(buffer); + +- GST_LOG_OBJECT (pwsink, "queue buffer %p, pw_buffer %p", buffer, data->b); +- + b = data->b->buffer; + + if (data->header) { +@@ -508,12 +508,15 @@ do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer) + data->crop->region.size.height = meta->width; + } + } ++ data->b->size = 0; + for (i = 0; i < b->n_datas; i++) { + struct spa_data *d = &b->datas[i]; + GstMemory *mem = gst_buffer_peek_memory (buffer, i); + d->chunk->offset = mem->offset; + d->chunk->size = mem->size; +- d->chunk->stride = pwsink->stream->pool->video_info.stride[i]; ++ d->chunk->stride = stream->pool->video_info.stride[i]; ++ ++ data->b->size += mem->size / 4; + } + + GstVideoMeta *meta = gst_buffer_get_video_meta (buffer); +@@ -532,9 +535,50 @@ do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer) + } + } + +- if ((res = pw_stream_queue_buffer (pwsink->stream->pwstream, data->b)) < 0) { ++ if ((res = pw_stream_queue_buffer (stream->pwstream, data->b)) < 0) { + g_warning ("can't send buffer %s", spa_strerror(res)); + } ++ ++ if (pwsink->rate_match) { ++ double err, corr; ++ struct pw_time ts; ++ guint64 queued, now, elapsed, target; ++ ++ pw_stream_get_time_n(stream->pwstream, &ts, sizeof(ts)); ++ now = pw_stream_get_nsec(stream->pwstream); ++ if (ts.now != 0) ++ elapsed = gst_util_uint64_scale_int (now - ts.now, ts.rate.denom, GST_SECOND * ts.rate.num); ++ else ++ elapsed = 0; ++ ++ queued = ts.queued - ts.size; ++ target = 2 * elapsed; ++ err = ((gint64)queued - ((gint64)target)); ++ ++ corr = spa_dll_update(&stream->dll, SPA_CLAMPD(err, -128.0, 128.0)); ++ ++ stream->err_wdw = (double)ts.rate.denom/ts.size; ++ ++ double avg = (stream->err_avg * stream->err_wdw + (err - stream->err_avg)) / (stream->err_wdw + 1.0); ++ stream->err_var = (stream->err_var * stream->err_wdw + ++ (err - stream->err_avg) * (err - avg)) / (stream->err_wdw + 1.0); ++ stream->err_avg = avg; ++ ++ if (stream->last_ts == 0 || stream->last_ts + SPA_NSEC_PER_SEC < now) { ++ stream->last_ts = now; ++ spa_dll_set_bw(&stream->dll, SPA_CLAMPD(fabs(stream->err_avg) / sqrt(fabs(stream->err_var)), 0.001, SPA_DLL_BW_MAX), ++ ts.size, ts.rate.denom); ++ GST_INFO_OBJECT (pwsink, "queue buffer %p, pw_buffer %p q:%"PRIi64"/%"PRIi64" e:%"PRIu64 ++ " err:%+03f corr:%f %f %f %f", ++ buffer, data->b, ts.queued, ts.size, elapsed, err, corr, ++ stream->err_avg, stream->err_var, stream->dll.bw); ++ } ++ ++ if (pwsink->match) { ++ pwsink->match->rate = corr; ++ SPA_FLAG_UPDATE(pwsink->match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE, true); ++ } ++ } + } + + +@@ -576,6 +620,18 @@ on_state_changed (void *data, enum pw_stream_state old, enum pw_stream_state sta + pw_thread_loop_signal (pwsink->stream->core->loop, FALSE); + } + ++static void ++on_io_changed (void *obj, uint32_t id, void *data, uint32_t size) ++{ ++ GstPipeWireSink *pwsink = obj; ++ ++ switch (id) { ++ case SPA_IO_RateMatch: ++ pwsink->match = data; ++ break; ++ } ++} ++ + static void + on_param_changed (void *data, uint32_t id, const struct spa_pod *param) + { +@@ -613,9 +669,16 @@ gst_pipewire_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) + pwsink = GST_PIPEWIRE_SINK (bsink); + + s = gst_caps_get_structure (caps, 0); +- rate = 0; +- if (gst_structure_has_name (s, "audio/x-raw")) ++ if (gst_structure_has_name (s, "audio/x-raw")) { + gst_structure_get_int (s, "rate", &rate); ++ pwsink->rate = rate; ++ pwsink->rate_match = true; ++ } else { ++ pwsink->rate = rate = 0; ++ pwsink->rate_match = false; ++ } ++ ++ spa_dll_set_bw(&pwsink->stream->dll, SPA_DLL_BW_MIN, 4096, rate); + + possible = gst_caps_to_format_all (caps); + +@@ -791,6 +854,7 @@ not_negotiated: + static const struct pw_stream_events stream_events = { + PW_VERSION_STREAM_EVENTS, + .state_changed = on_state_changed, ++ .io_changed = on_io_changed, + .param_changed = on_param_changed, + .add_buffer = on_add_buffer, + .remove_buffer = on_remove_buffer, +diff --git a/src/gst/gstpipewiresink.h b/src/gst/gstpipewiresink.h +index 74e6667e6..33d7b5b4f 100644 +--- a/src/gst/gstpipewiresink.h ++++ b/src/gst/gstpipewiresink.h +@@ -50,8 +50,12 @@ struct _GstPipeWireSink { + + /* video state */ + gboolean negotiated; ++ gboolean rate_match; ++ gint rate; + + GstPipeWireSinkMode mode; ++ ++ struct spa_io_rate_match *match; + }; + + GType gst_pipewire_sink_mode_get_type (void); +diff --git a/src/gst/gstpipewirestream.c b/src/gst/gstpipewirestream.c +index bf7641548..68cb9be21 100644 +--- a/src/gst/gstpipewirestream.c ++++ b/src/gst/gstpipewirestream.c +@@ -19,6 +19,7 @@ gst_pipewire_stream_init (GstPipeWireStream * self) + self->fd = -1; + self->client_name = g_strdup (pw_get_client_name()); + self->pool = gst_pipewire_pool_new (self); ++ spa_dll_init(&self->dll); + } + + static void +diff --git a/src/gst/gstpipewirestream.h b/src/gst/gstpipewirestream.h +index ff8c8e2e6..a301375c7 100644 +--- a/src/gst/gstpipewirestream.h ++++ b/src/gst/gstpipewirestream.h +@@ -11,6 +11,7 @@ + #include "gstpipewirecore.h" + + #include <gst/gst.h> ++#include <spa/utils/dll.h> + #include <pipewire/pipewire.h> + + G_BEGIN_DECLS +@@ -29,6 +30,13 @@ struct _GstPipeWireStream { + GstPipeWirePool *pool; + GstClock *clock; + ++ guint64 position; ++ struct spa_dll dll; ++ double err_avg, err_var, err_wdw; ++ guint64 last_ts; ++ guint64 base_buffer_ts; ++ guint64 base_ts; ++ + /* the actual pw stream */ + struct pw_stream *pwstream; + struct spa_hook pwstream_listener; +diff --git a/src/gst/meson.build b/src/gst/meson.build +index ba1f6d558..1e39bcf89 100644 +--- a/src/gst/meson.build ++++ b/src/gst/meson.build +@@ -27,7 +27,7 @@ pipewire_gst_headers = [ + pipewire_gst = shared_library('gstpipewire', + pipewire_gst_sources, + include_directories : [ configinc ], +- dependencies : [ spa_dep, gst_dep, pipewire_dep ], ++ dependencies : [ spa_dep, gst_dep, pipewire_dep, mathlib ], + install : true, + install_dir : '@0@/gstreamer-1.0'.format(get_option('libdir')), + ) +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0005-gst-add-slave-method-property.patch b/media-video/pipewire/files/1.2.7/0005-gst-add-slave-method-property.patch new file mode 100644 index 000000000000..74df92bbdfcf --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0005-gst-add-slave-method-property.patch @@ -0,0 +1,259 @@ +From 91e26d6011bd194deffb5765f9b3306fb92738d9 Mon Sep 17 00:00:00 2001 +Message-ID: <91e26d6011bd194deffb5765f9b3306fb92738d9.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Tue, 3 Dec 2024 11:54:52 +0100 +Subject: [PATCH 5/8] gst: add slave-method property + +Set the slave-method to none by default to disable the resampler. + +Fixes #4374 +--- + src/gst/gstpipewiresink.c | 141 +++++++++++++++++++++++++++----------- + src/gst/gstpipewiresink.h | 21 +++++- + 2 files changed, 120 insertions(+), 42 deletions(-) + +diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c +index 33f2322e9..bf1b427f0 100644 +--- a/src/gst/gstpipewiresink.c ++++ b/src/gst/gstpipewiresink.c +@@ -37,6 +37,7 @@ GST_DEBUG_CATEGORY_STATIC (pipewire_sink_debug); + #define GST_CAT_DEFAULT pipewire_sink_debug + + #define DEFAULT_PROP_MODE GST_PIPEWIRE_SINK_MODE_DEFAULT ++#define DEFAULT_PROP_SLAVE_METHOD GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE + + #define MIN_BUFFERS 8u + +@@ -49,7 +50,8 @@ enum + PROP_CLIENT_PROPERTIES, + PROP_STREAM_PROPERTIES, + PROP_MODE, +- PROP_FD ++ PROP_FD, ++ PROP_SLAVE_METHOD + }; + + GType +@@ -72,6 +74,26 @@ gst_pipewire_sink_mode_get_type (void) + return (GType) mode_type; + } + ++GType ++gst_pipewire_sink_slave_method_get_type (void) ++{ ++ static gsize method_type = 0; ++ static const GEnumValue method[] = { ++ {GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE, "GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE", "none"}, ++ {GST_PIPEWIRE_SINK_SLAVE_METHOD_RESAMPLE, "GST_PIPEWIRE_SINK_SLAVE_METHOD_RESAMPLE", "resample"}, ++ {0, NULL, NULL}, ++ }; ++ ++ if (g_once_init_enter (&method_type)) { ++ GType tmp = ++ g_enum_register_static ("GstPipeWireSinkSlaveMethod", method); ++ g_once_init_leave (&method_type, tmp); ++ } ++ ++ return (GType) method_type; ++} ++ ++ + + static GstStaticPadTemplate gst_pipewire_sink_template = + GST_STATIC_PAD_TEMPLATE ("sink", +@@ -225,6 +247,17 @@ gst_pipewire_sink_class_init (GstPipeWireSinkClass * klass) + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + ++ g_object_class_install_property (gobject_class, ++ PROP_SLAVE_METHOD, ++ g_param_spec_enum ("slave-method", ++ "Slave Method", ++ "Algorithm used to match the rate of the masterclock", ++ GST_TYPE_PIPEWIRE_SINK_SLAVE_METHOD, ++ DEFAULT_PROP_SLAVE_METHOD, ++ G_PARAM_READWRITE | ++ G_PARAM_STATIC_STRINGS)); ++ ++ + gstelement_class->provide_clock = gst_pipewire_sink_provide_clock; + gstelement_class->change_state = gst_pipewire_sink_change_state; + +@@ -408,6 +441,10 @@ gst_pipewire_sink_set_property (GObject * object, guint prop_id, + pwsink->stream->fd = g_value_get_int (value); + break; + ++ case PROP_SLAVE_METHOD: ++ pwsink->slave_method = g_value_get_enum (value); ++ break; ++ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; +@@ -449,12 +486,69 @@ gst_pipewire_sink_get_property (GObject * object, guint prop_id, + g_value_set_int (value, pwsink->stream->fd); + break; + ++ case PROP_SLAVE_METHOD: ++ g_value_set_enum (value, pwsink->slave_method); ++ break; ++ + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + } + ++static void rate_match_resample(GstPipeWireSink *pwsink) ++{ ++ GstPipeWireStream *stream = pwsink->stream; ++ double err, corr; ++ struct pw_time ts; ++ guint64 queued, now, elapsed, target; ++ ++ if (!pwsink->rate_match) ++ return; ++ ++ pw_stream_get_time_n(stream->pwstream, &ts, sizeof(ts)); ++ now = pw_stream_get_nsec(stream->pwstream); ++ if (ts.now != 0) ++ elapsed = gst_util_uint64_scale_int (now - ts.now, ts.rate.denom, GST_SECOND * ts.rate.num); ++ else ++ elapsed = 0; ++ ++ queued = ts.queued - ts.size; ++ target = elapsed; ++ err = ((gint64)queued - ((gint64)target)); ++ ++ corr = spa_dll_update(&stream->dll, SPA_CLAMPD(err, -128.0, 128.0)); ++ ++ stream->err_wdw = (double)ts.rate.denom/ts.size; ++ ++ double avg = (stream->err_avg * stream->err_wdw + (err - stream->err_avg)) / (stream->err_wdw + 1.0); ++ stream->err_var = (stream->err_var * stream->err_wdw + ++ (err - stream->err_avg) * (err - avg)) / (stream->err_wdw + 1.0); ++ stream->err_avg = avg; ++ ++ if (stream->last_ts == 0 || stream->last_ts + SPA_NSEC_PER_SEC < now) { ++ double bw; ++ ++ stream->last_ts = now; ++ ++ if (stream->err_var == 0.0) ++ bw = 0.0; ++ else ++ bw = fabs(stream->err_avg) / sqrt(fabs(stream->err_var)); ++ ++ spa_dll_set_bw(&stream->dll, SPA_CLAMPD(bw, 0.001, SPA_DLL_BW_MAX), ts.size, ts.rate.denom); ++ ++ GST_INFO_OBJECT (pwsink, "q:%"PRIi64"/%"PRIi64" e:%"PRIu64" err:%+03f corr:%f %f %f %f", ++ ts.queued, ts.size, elapsed, err, corr, ++ stream->err_avg, stream->err_var, stream->dll.bw); ++ } ++ ++ if (pwsink->match) { ++ pwsink->match->rate = corr; ++ SPA_FLAG_UPDATE(pwsink->match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE, true); ++ } ++} ++ + static void + on_add_buffer (void *_data, struct pw_buffer *b) + { +@@ -539,45 +633,12 @@ do_send_buffer (GstPipeWireSink *pwsink, GstBuffer *buffer) + g_warning ("can't send buffer %s", spa_strerror(res)); + } + +- if (pwsink->rate_match) { +- double err, corr; +- struct pw_time ts; +- guint64 queued, now, elapsed, target; +- +- pw_stream_get_time_n(stream->pwstream, &ts, sizeof(ts)); +- now = pw_stream_get_nsec(stream->pwstream); +- if (ts.now != 0) +- elapsed = gst_util_uint64_scale_int (now - ts.now, ts.rate.denom, GST_SECOND * ts.rate.num); +- else +- elapsed = 0; +- +- queued = ts.queued - ts.size; +- target = 2 * elapsed; +- err = ((gint64)queued - ((gint64)target)); +- +- corr = spa_dll_update(&stream->dll, SPA_CLAMPD(err, -128.0, 128.0)); +- +- stream->err_wdw = (double)ts.rate.denom/ts.size; +- +- double avg = (stream->err_avg * stream->err_wdw + (err - stream->err_avg)) / (stream->err_wdw + 1.0); +- stream->err_var = (stream->err_var * stream->err_wdw + +- (err - stream->err_avg) * (err - avg)) / (stream->err_wdw + 1.0); +- stream->err_avg = avg; +- +- if (stream->last_ts == 0 || stream->last_ts + SPA_NSEC_PER_SEC < now) { +- stream->last_ts = now; +- spa_dll_set_bw(&stream->dll, SPA_CLAMPD(fabs(stream->err_avg) / sqrt(fabs(stream->err_var)), 0.001, SPA_DLL_BW_MAX), +- ts.size, ts.rate.denom); +- GST_INFO_OBJECT (pwsink, "queue buffer %p, pw_buffer %p q:%"PRIi64"/%"PRIi64" e:%"PRIu64 +- " err:%+03f corr:%f %f %f %f", +- buffer, data->b, ts.queued, ts.size, elapsed, err, corr, +- stream->err_avg, stream->err_var, stream->dll.bw); +- } +- +- if (pwsink->match) { +- pwsink->match->rate = corr; +- SPA_FLAG_UPDATE(pwsink->match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE, true); +- } ++ switch (pwsink->slave_method) { ++ case GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE: ++ break; ++ case GST_PIPEWIRE_SINK_SLAVE_METHOD_RESAMPLE: ++ rate_match_resample(pwsink); ++ break; + } + } + +diff --git a/src/gst/gstpipewiresink.h b/src/gst/gstpipewiresink.h +index 33d7b5b4f..306297d0e 100644 +--- a/src/gst/gstpipewiresink.h ++++ b/src/gst/gstpipewiresink.h +@@ -37,6 +37,22 @@ typedef enum + + #define GST_TYPE_PIPEWIRE_SINK_MODE (gst_pipewire_sink_mode_get_type ()) + ++ ++/** ++ * GstPipeWireSinkSlaveMethod: ++ * @GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE: no clock and timestamp slaving ++ * @GST_PIPEWIRE_SINK_SLAVE_METHOD_RESAMPLE: resample audio ++ * ++ * Different clock slaving methods ++ */ ++typedef enum ++{ ++ GST_PIPEWIRE_SINK_SLAVE_METHOD_NONE, ++ GST_PIPEWIRE_SINK_SLAVE_METHOD_RESAMPLE, ++} GstPipeWireSinkSlaveMethod; ++ ++#define GST_TYPE_PIPEWIRE_SINK_SLAVE_METHOD (gst_pipewire_sink_slave_method_get_type ()) ++ + /** + * GstPipeWireSink: + * +@@ -53,9 +69,10 @@ struct _GstPipeWireSink { + gboolean rate_match; + gint rate; + +- GstPipeWireSinkMode mode; +- + struct spa_io_rate_match *match; ++ ++ GstPipeWireSinkMode mode; ++ GstPipeWireSinkSlaveMethod slave_method; + }; + + GType gst_pipewire_sink_mode_get_type (void); +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0006-spa-fix-some-param-type-info.patch b/media-video/pipewire/files/1.2.7/0006-spa-fix-some-param-type-info.patch new file mode 100644 index 000000000000..c91ada71cf5a --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0006-spa-fix-some-param-type-info.patch @@ -0,0 +1,51 @@ +From e42de413e89249dca22b78f3c3d5a5c2e2e8b2f3 Mon Sep 17 00:00:00 2001 +Message-ID: <e42de413e89249dca22b78f3c3d5a5c2e2e8b2f3.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Tue, 3 Dec 2024 12:41:07 +0100 +Subject: [PATCH 6/8] spa: fix some param type info + +Add an int array type and use this in the route properties. + +Fixes #4441 +--- + spa/include/spa/param/param-types.h | 5 +++++ + spa/include/spa/param/route-types.h | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/spa/include/spa/param/param-types.h b/spa/include/spa/param/param-types.h +index 4bed3651d..ebb8d988b 100644 +--- a/spa/include/spa/param/param-types.h ++++ b/spa/include/spa/param/param-types.h +@@ -55,6 +55,11 @@ static const struct spa_type_info spa_type_prop_float_array[] = { + { 0, 0, NULL, NULL }, + }; + ++static const struct spa_type_info spa_type_prop_int_array[] = { ++ { SPA_PROP_START, SPA_TYPE_Int, SPA_TYPE_INFO_BASE "intArray", NULL, }, ++ { 0, 0, NULL, NULL }, ++}; ++ + static const struct spa_type_info spa_type_prop_channel_map[] = { + { SPA_PROP_START, SPA_TYPE_Id, SPA_TYPE_INFO_BASE "channelMap", spa_type_audio_channel, }, + { 0, 0, NULL, NULL }, +diff --git a/spa/include/spa/param/route-types.h b/spa/include/spa/param/route-types.h +index 619a9e2e8..78ced495e 100644 +--- a/spa/include/spa/param/route-types.h ++++ b/spa/include/spa/param/route-types.h +@@ -32,9 +32,9 @@ static const struct spa_type_info spa_type_param_route[] = { + { SPA_PARAM_ROUTE_priority, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "priority", NULL, }, + { SPA_PARAM_ROUTE_available, SPA_TYPE_Id, SPA_TYPE_INFO_PARAM_ROUTE_BASE "available", spa_type_param_availability, }, + { SPA_PARAM_ROUTE_info, SPA_TYPE_Struct, SPA_TYPE_INFO_PARAM_ROUTE_BASE "info", NULL, }, +- { SPA_PARAM_ROUTE_profiles, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "profiles", NULL, }, ++ { SPA_PARAM_ROUTE_profiles, SPA_TYPE_Array, SPA_TYPE_INFO_PARAM_ROUTE_BASE "profiles", spa_type_prop_int_array, }, + { SPA_PARAM_ROUTE_props, SPA_TYPE_OBJECT_Props, SPA_TYPE_INFO_PARAM_ROUTE_BASE "props", NULL, }, +- { SPA_PARAM_ROUTE_devices, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "devices", NULL, }, ++ { SPA_PARAM_ROUTE_devices, SPA_TYPE_Array, SPA_TYPE_INFO_PARAM_ROUTE_BASE "devices", spa_type_prop_int_array, }, + { SPA_PARAM_ROUTE_profile, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "profile", NULL, }, + { SPA_PARAM_ROUTE_save, SPA_TYPE_Bool, SPA_TYPE_INFO_PARAM_ROUTE_BASE "save", NULL, }, + { 0, 0, NULL, NULL }, +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0007-filter-chain-handle-0-length-IR.patch b/media-video/pipewire/files/1.2.7/0007-filter-chain-handle-0-length-IR.patch new file mode 100644 index 000000000000..4a1c25871d4c --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0007-filter-chain-handle-0-length-IR.patch @@ -0,0 +1,305 @@ +From 8d9269374ddd7fc1628d9bf05c0880e82a76015d Mon Sep 17 00:00:00 2001 +Message-ID: <8d9269374ddd7fc1628d9bf05c0880e82a76015d.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Tue, 3 Dec 2024 15:43:56 +0100 +Subject: [PATCH 7/8] filter-chain: handle 0 length IR + +Make sure we copy the DSP functions in the convolver before leaving the +function because we need them to clear memory. + +Don't store the DSP functions in the head and tail convolvers but pass +them from the main convolver because the convolvers might be NULL but we +still need the DSP functions to clear memory. + +Fixes #4433 +--- + src/modules/module-filter-chain/convolver.c | 96 +++++++++++---------- + 1 file changed, 49 insertions(+), 47 deletions(-) + +diff --git a/src/modules/module-filter-chain/convolver.c b/src/modules/module-filter-chain/convolver.c +index 3aa7230c0..4251c4025 100644 +--- a/src/modules/module-filter-chain/convolver.c ++++ b/src/modules/module-filter-chain/convolver.c +@@ -11,8 +11,6 @@ + #include <math.h> + + struct convolver1 { +- struct dsp_ops *dsp; +- + int blockSize; + int segSize; + int segCount; +@@ -76,15 +74,15 @@ static int next_power_of_two(int val) + return r; + } + +-static void convolver1_reset(struct convolver1 *conv) ++static void convolver1_reset(struct dsp_ops *dsp, struct convolver1 *conv) + { + int i; + for (i = 0; i < conv->segCount; i++) +- fft_cpx_clear(conv->dsp, conv->segments[i], conv->fftComplexSize); +- dsp_ops_clear(conv->dsp, conv->overlap, conv->blockSize); +- dsp_ops_clear(conv->dsp, conv->inputBuffer, conv->segSize); +- fft_cpx_clear(conv->dsp, conv->pre_mult, conv->fftComplexSize); +- fft_cpx_clear(conv->dsp, conv->conv, conv->fftComplexSize); ++ fft_cpx_clear(dsp, conv->segments[i], conv->fftComplexSize); ++ dsp_ops_clear(dsp, conv->overlap, conv->blockSize); ++ dsp_ops_clear(dsp, conv->inputBuffer, conv->segSize); ++ fft_cpx_clear(dsp, conv->pre_mult, conv->fftComplexSize); ++ fft_cpx_clear(dsp, conv->conv, conv->fftComplexSize); + conv->inputBufferFill = 0; + conv->current = 0; + } +@@ -107,16 +105,15 @@ static struct convolver1 *convolver1_new(struct dsp_ops *dsp, int block, const f + if (irlen == 0) + return conv; + +- conv->dsp = dsp; + conv->blockSize = next_power_of_two(block); + conv->segSize = 2 * conv->blockSize; + conv->segCount = (irlen + conv->blockSize-1) / conv->blockSize; + conv->fftComplexSize = (conv->segSize / 2) + 1; + +- conv->fft = dsp_ops_fft_new(conv->dsp, conv->segSize, true); ++ conv->fft = dsp_ops_fft_new(dsp, conv->segSize, true); + if (conv->fft == NULL) + goto error; +- conv->ifft = dsp_ops_fft_new(conv->dsp, conv->segSize, true); ++ conv->ifft = dsp_ops_fft_new(dsp, conv->segSize, true); + if (conv->ifft == NULL) + goto error; + +@@ -134,18 +131,18 @@ static struct convolver1 *convolver1_new(struct dsp_ops *dsp, int block, const f + conv->segments[i] = fft_cpx_alloc(conv->fftComplexSize); + conv->segmentsIr[i] = fft_cpx_alloc(conv->fftComplexSize); + +- dsp_ops_copy(conv->dsp, conv->fft_buffer, &ir[i * conv->blockSize], copy); ++ dsp_ops_copy(dsp, conv->fft_buffer, &ir[i * conv->blockSize], copy); + if (copy < conv->segSize) +- dsp_ops_clear(conv->dsp, conv->fft_buffer + copy, conv->segSize - copy); ++ dsp_ops_clear(dsp, conv->fft_buffer + copy, conv->segSize - copy); + +- dsp_ops_fft_run(conv->dsp, conv->fft, 1, conv->fft_buffer, conv->segmentsIr[i]); ++ dsp_ops_fft_run(dsp, conv->fft, 1, conv->fft_buffer, conv->segmentsIr[i]); + } + conv->pre_mult = fft_cpx_alloc(conv->fftComplexSize); + conv->conv = fft_cpx_alloc(conv->fftComplexSize); + conv->overlap = fft_alloc(conv->blockSize); + conv->inputBuffer = fft_alloc(conv->segSize); + conv->scale = 1.0f / conv->segSize; +- convolver1_reset(conv); ++ convolver1_reset(dsp, conv); + + return conv; + error: +@@ -159,7 +156,7 @@ error: + return NULL; + } + +-static void convolver1_free(struct convolver1 *conv) ++static void convolver1_free(struct dsp_ops *dsp, struct convolver1 *conv) + { + int i; + for (i = 0; i < conv->segCount; i++) { +@@ -167,9 +164,9 @@ static void convolver1_free(struct convolver1 *conv) + fft_cpx_free(conv->segmentsIr[i]); + } + if (conv->fft) +- dsp_ops_fft_free(conv->dsp, conv->fft); ++ dsp_ops_fft_free(dsp, conv->fft); + if (conv->ifft) +- dsp_ops_fft_free(conv->dsp, conv->ifft); ++ dsp_ops_fft_free(dsp, conv->ifft); + if (conv->fft_buffer) + fft_free(conv->fft_buffer); + free(conv->segments); +@@ -181,12 +178,12 @@ static void convolver1_free(struct convolver1 *conv) + free(conv); + } + +-static int convolver1_run(struct convolver1 *conv, const float *input, float *output, int len) ++static int convolver1_run(struct dsp_ops *dsp, struct convolver1 *conv, const float *input, float *output, int len) + { + int i, processed = 0; + + if (conv == NULL || conv->segCount == 0) { +- dsp_ops_clear(conv->dsp, output, len); ++ dsp_ops_clear(dsp, output, len); + return len; + } + +@@ -194,17 +191,17 @@ static int convolver1_run(struct convolver1 *conv, const float *input, float *ou + const int processing = SPA_MIN(len - processed, conv->blockSize - conv->inputBufferFill); + const int inputBufferPos = conv->inputBufferFill; + +- dsp_ops_copy(conv->dsp, conv->inputBuffer + inputBufferPos, input + processed, processing); ++ dsp_ops_copy(dsp, conv->inputBuffer + inputBufferPos, input + processed, processing); + if (inputBufferPos == 0 && processing < conv->blockSize) +- dsp_ops_clear(conv->dsp, conv->inputBuffer + processing, conv->blockSize - processing); ++ dsp_ops_clear(dsp, conv->inputBuffer + processing, conv->blockSize - processing); + +- dsp_ops_fft_run(conv->dsp, conv->fft, 1, conv->inputBuffer, conv->segments[conv->current]); ++ dsp_ops_fft_run(dsp, conv->fft, 1, conv->inputBuffer, conv->segments[conv->current]); + + if (conv->segCount > 1) { + if (conv->inputBufferFill == 0) { + int indexAudio = (conv->current + 1) % conv->segCount; + +- dsp_ops_fft_cmul(conv->dsp, conv->fft, conv->pre_mult, ++ dsp_ops_fft_cmul(dsp, conv->fft, conv->pre_mult, + conv->segmentsIr[1], + conv->segments[indexAudio], + conv->fftComplexSize, conv->scale); +@@ -212,7 +209,7 @@ static int convolver1_run(struct convolver1 *conv, const float *input, float *ou + for (i = 2; i < conv->segCount; i++) { + indexAudio = (conv->current + i) % conv->segCount; + +- dsp_ops_fft_cmuladd(conv->dsp, conv->fft, ++ dsp_ops_fft_cmuladd(dsp, conv->fft, + conv->pre_mult, + conv->pre_mult, + conv->segmentsIr[i], +@@ -220,30 +217,30 @@ static int convolver1_run(struct convolver1 *conv, const float *input, float *ou + conv->fftComplexSize, conv->scale); + } + } +- dsp_ops_fft_cmuladd(conv->dsp, conv->fft, ++ dsp_ops_fft_cmuladd(dsp, conv->fft, + conv->conv, + conv->pre_mult, + conv->segments[conv->current], + conv->segmentsIr[0], + conv->fftComplexSize, conv->scale); + } else { +- dsp_ops_fft_cmul(conv->dsp, conv->fft, ++ dsp_ops_fft_cmul(dsp, conv->fft, + conv->conv, + conv->segments[conv->current], + conv->segmentsIr[0], + conv->fftComplexSize, conv->scale); + } + +- dsp_ops_fft_run(conv->dsp, conv->ifft, -1, conv->conv, conv->fft_buffer); ++ dsp_ops_fft_run(dsp, conv->ifft, -1, conv->conv, conv->fft_buffer); + +- dsp_ops_sum(conv->dsp, output + processed, conv->fft_buffer + inputBufferPos, ++ dsp_ops_sum(dsp, output + processed, conv->fft_buffer + inputBufferPos, + conv->overlap + inputBufferPos, processing); + + conv->inputBufferFill += processing; + if (conv->inputBufferFill == conv->blockSize) { + conv->inputBufferFill = 0; + +- dsp_ops_copy(conv->dsp, conv->overlap, conv->fft_buffer + conv->blockSize, conv->blockSize); ++ dsp_ops_copy(dsp, conv->overlap, conv->fft_buffer + conv->blockSize, conv->blockSize); + + conv->current = (conv->current > 0) ? (conv->current - 1) : (conv->segCount - 1); + } +@@ -272,17 +269,18 @@ struct convolver + + void convolver_reset(struct convolver *conv) + { ++ struct dsp_ops *dsp = conv->dsp; + if (conv->headConvolver) +- convolver1_reset(conv->headConvolver); ++ convolver1_reset(dsp, conv->headConvolver); + if (conv->tailConvolver0) { +- convolver1_reset(conv->tailConvolver0); +- dsp_ops_clear(conv->dsp, conv->tailOutput0, conv->tailBlockSize); +- dsp_ops_clear(conv->dsp, conv->tailPrecalculated0, conv->tailBlockSize); ++ convolver1_reset(dsp, conv->tailConvolver0); ++ dsp_ops_clear(dsp, conv->tailOutput0, conv->tailBlockSize); ++ dsp_ops_clear(dsp, conv->tailPrecalculated0, conv->tailBlockSize); + } + if (conv->tailConvolver) { +- convolver1_reset(conv->tailConvolver); +- dsp_ops_clear(conv->dsp, conv->tailOutput, conv->tailBlockSize); +- dsp_ops_clear(conv->dsp, conv->tailPrecalculated, conv->tailBlockSize); ++ convolver1_reset(dsp, conv->tailConvolver); ++ dsp_ops_clear(dsp, conv->tailOutput, conv->tailBlockSize); ++ dsp_ops_clear(dsp, conv->tailPrecalculated, conv->tailBlockSize); + } + conv->tailInputFill = 0; + conv->precalculatedPos = 0; +@@ -307,10 +305,11 @@ struct convolver *convolver_new(struct dsp_ops *dsp_ops, int head_block, int tai + if (conv == NULL) + return NULL; + ++ conv->dsp = dsp_ops; ++ + if (irlen == 0) + return conv; + +- conv->dsp = dsp_ops; + conv->headBlockSize = next_power_of_two(head_block); + conv->tailBlockSize = next_power_of_two(tail_block); + +@@ -341,12 +340,13 @@ struct convolver *convolver_new(struct dsp_ops *dsp_ops, int head_block, int tai + + void convolver_free(struct convolver *conv) + { ++ struct dsp_ops *dsp = conv->dsp; + if (conv->headConvolver) +- convolver1_free(conv->headConvolver); ++ convolver1_free(dsp, conv->headConvolver); + if (conv->tailConvolver0) +- convolver1_free(conv->tailConvolver0); ++ convolver1_free(dsp, conv->tailConvolver0); + if (conv->tailConvolver) +- convolver1_free(conv->tailConvolver); ++ convolver1_free(dsp, conv->tailConvolver); + fft_free(conv->tailOutput0); + fft_free(conv->tailPrecalculated0); + fft_free(conv->tailOutput); +@@ -357,7 +357,9 @@ void convolver_free(struct convolver *conv) + + int convolver_run(struct convolver *conv, const float *input, float *output, int length) + { +- convolver1_run(conv->headConvolver, input, output, length); ++ struct dsp_ops *dsp = conv->dsp; ++ ++ convolver1_run(dsp, conv->headConvolver, input, output, length); + + if (conv->tailInput) { + int processed = 0; +@@ -367,21 +369,21 @@ int convolver_run(struct convolver *conv, const float *input, float *output, int + int processing = SPA_MIN(remaining, conv->headBlockSize - (conv->tailInputFill % conv->headBlockSize)); + + if (conv->tailPrecalculated0) +- dsp_ops_sum(conv->dsp, &output[processed], &output[processed], ++ dsp_ops_sum(dsp, &output[processed], &output[processed], + &conv->tailPrecalculated0[conv->precalculatedPos], + processing); + if (conv->tailPrecalculated) +- dsp_ops_sum(conv->dsp, &output[processed], &output[processed], ++ dsp_ops_sum(dsp, &output[processed], &output[processed], + &conv->tailPrecalculated[conv->precalculatedPos], + processing); + conv->precalculatedPos += processing; + +- dsp_ops_copy(conv->dsp, conv->tailInput + conv->tailInputFill, input + processed, processing); ++ dsp_ops_copy(dsp, conv->tailInput + conv->tailInputFill, input + processed, processing); + conv->tailInputFill += processing; + + if (conv->tailPrecalculated0 && (conv->tailInputFill % conv->headBlockSize == 0)) { + int blockOffset = conv->tailInputFill - conv->headBlockSize; +- convolver1_run(conv->tailConvolver0, ++ convolver1_run(dsp, conv->tailConvolver0, + conv->tailInput + blockOffset, + conv->tailOutput0 + blockOffset, + conv->headBlockSize); +@@ -392,7 +394,7 @@ int convolver_run(struct convolver *conv, const float *input, float *output, int + if (conv->tailPrecalculated && + conv->tailInputFill == conv->tailBlockSize) { + SPA_SWAP(conv->tailPrecalculated, conv->tailOutput); +- convolver1_run(conv->tailConvolver, conv->tailInput, ++ convolver1_run(dsp, conv->tailConvolver, conv->tailInput, + conv->tailOutput, conv->tailBlockSize); + } + if (conv->tailInputFill == conv->tailBlockSize) { +-- +2.48.0 + diff --git a/media-video/pipewire/files/1.2.7/0008-spa-initialize-all-fields-explicitly.patch b/media-video/pipewire/files/1.2.7/0008-spa-initialize-all-fields-explicitly.patch new file mode 100644 index 000000000000..24b99891cee2 --- /dev/null +++ b/media-video/pipewire/files/1.2.7/0008-spa-initialize-all-fields-explicitly.patch @@ -0,0 +1,47 @@ +From 223569dc4a5778bf74f6d072b10e71912f8b5418 Mon Sep 17 00:00:00 2001 +Message-ID: <223569dc4a5778bf74f6d072b10e71912f8b5418.1737052666.git....@gentoo.org> +In-Reply-To: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +References: <1993383ddf67e296334c7916d6afc699ee6300c7.1737052666.git....@gentoo.org> +From: Wim Taymans <[email protected]> +Date: Mon, 30 Sep 2024 10:06:30 +0200 +Subject: [PATCH 8/8] spa: initialize all fields explicitly + +Patch by Petar Popovic + +Fixes #4325 + +(cherry picked from commit 0ca64277b317b4836beccaa3248ab9055526811c) +--- + spa/include/spa/pod/builder.h | 2 +- + spa/include/spa/pod/parser.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h +index 0564d94ea..6d3e9d54a 100644 +--- a/spa/include/spa/pod/builder.h ++++ b/spa/include/spa/pod/builder.h +@@ -49,7 +49,7 @@ struct spa_pod_builder { + struct spa_callbacks callbacks; + }; + +-#define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {0}, {0} }) ++#define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {0,0,NULL},{NULL,NULL}}) + + static inline void + spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state) +diff --git a/spa/include/spa/pod/parser.h b/spa/include/spa/pod/parser.h +index 083f91171..4c1e72acc 100644 +--- a/spa/include/spa/pod/parser.h ++++ b/spa/include/spa/pod/parser.h +@@ -33,7 +33,7 @@ struct spa_pod_parser { + struct spa_pod_parser_state state; + }; + +-#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {0} }) ++#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {0,0,NULL}}) + + static inline void spa_pod_parser_init(struct spa_pod_parser *parser, + const void *data, uint32_t size) +-- +2.48.0 + diff --git a/media-video/pipewire/pipewire-1.2.7.ebuild b/media-video/pipewire/pipewire-1.2.7-r1.ebuild similarity index 99% copy from media-video/pipewire/pipewire-1.2.7.ebuild copy to media-video/pipewire/pipewire-1.2.7-r1.ebuild index 63b0b609e159..36f4674429fd 100644 --- a/media-video/pipewire/pipewire-1.2.7.ebuild +++ b/media-video/pipewire/pipewire-1.2.7-r1.ebuild @@ -47,7 +47,7 @@ else PIPEWIRE_DOCS_USEFLAG="man" fi - KEYWORDS="amd64 arm arm64 ~loong ~mips ppc ppc64 ~riscv ~sparc x86" + KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" fi DESCRIPTION="Multimedia processing graphs" diff --git a/media-video/pipewire/pipewire-1.2.7.ebuild b/media-video/pipewire/pipewire-1.2.7.ebuild index 63b0b609e159..bcfeeafff3df 100644 --- a/media-video/pipewire/pipewire-1.2.7.ebuild +++ b/media-video/pipewire/pipewire-1.2.7.ebuild @@ -188,7 +188,7 @@ src_prepare() { default # Used for upstream backports - [[ -d "${FILESDIR}"/${PV} ]] && eapply "${FILESDIR}"/${PV} + #[[ -d "${FILESDIR}"/${PV} ]] && eapply "${FILESDIR}"/${PV} } multilib_src_configure() {
