media-video/pipewire: backport recommended upstream patches to 0.3.83

Bug: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3592
Bug: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3593
Bug: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3600
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2023-10-25 02:30:27 +01:00
parent d3c8c3c88a
commit e78e092c51
4 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3592
https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/3d8c7c40b5cc16eaf7bd1fb72c17783ce42e2d0e
From 3d8c7c40b5cc16eaf7bd1fb72c17783ce42e2d0e Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Fri, 20 Oct 2023 09:57:52 +0200
Subject: [PATCH] stream: improve queued_buffers reporting
Also add the queued buffers in the converter to the pw_time.queued_buffers
field. This means that queued_buffers + avail_buffers always equal the
total amount of allocated buffers, which makes more sense.
Fixes #3592
--- a/src/pipewire/stream.c
+++ b/src/pipewire/stream.c
@@ -2340,6 +2340,7 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
uintptr_t seq1, seq2;
uint32_t buffered, quantum, index;
+ int32_t avail_buffers;
do {
seq1 = SPA_SEQ_READ(impl->seq);
@@ -2358,19 +2359,23 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
time->delay += (impl->latency.min_rate + impl->latency.max_rate) / 2;
time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) * time->rate.denom / SPA_NSEC_PER_SEC;
+ avail_buffers = spa_ringbuffer_get_read_index(&impl->dequeued.ring, &index);
+ avail_buffers = SPA_CLAMP(avail_buffers, 0, (int32_t)impl->n_buffers);
+
if (size >= offsetof(struct pw_time, queued_buffers))
time->buffered = buffered;
if (size >= offsetof(struct pw_time, avail_buffers))
- time->queued_buffers = spa_ringbuffer_get_read_index(&impl->queued.ring, &index);
+ time->queued_buffers = impl->n_buffers - avail_buffers;
if (size >= sizeof(struct pw_time))
- time->avail_buffers = spa_ringbuffer_get_read_index(&impl->dequeued.ring, &index);
+ time->avail_buffers = avail_buffers;
pw_log_trace_fp("%p: %"PRIi64" %"PRIi64" %"PRIu64" %d/%d %"PRIu64" %"
- PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, stream,
+ PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %d/%d", stream,
time->now, time->delay, time->ticks,
time->rate.num, time->rate.denom, time->queued,
impl->dequeued.outcount, impl->dequeued.incount,
- impl->queued.outcount, impl->queued.incount);
+ impl->queued.outcount, impl->queued.incount,
+ avail_buffers, impl->n_buffers);
return 0;
}
--
GitLab

View File

@@ -0,0 +1,36 @@
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3593
https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/93d5848031cd9101d830fb4c37c5a7404ac5f276
From 93d5848031cd9101d830fb4c37c5a7404ac5f276 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Sat, 21 Oct 2023 09:27:43 +0200
Subject: [PATCH] module-echo-cancel: playback and source are async
The playback and source streams don't dequeue/queue buffers from
the process function and so need to be marked async.
Fixes #3593
--- a/src/modules/module-echo-cancel.c
+++ b/src/modules/module-echo-cancel.c
@@ -1002,7 +1002,8 @@ static int setup_streams(struct impl *impl)
PW_DIRECTION_OUTPUT,
PW_ID_ANY,
PW_STREAM_FLAG_MAP_BUFFERS |
- PW_STREAM_FLAG_RT_PROCESS,
+ PW_STREAM_FLAG_RT_PROCESS |
+ PW_STREAM_FLAG_ASYNC,
params, n_params)) < 0) {
spa_pod_dynamic_builder_clean(&b);
return res;
@@ -1036,7 +1037,8 @@ static int setup_streams(struct impl *impl)
PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS |
- PW_STREAM_FLAG_RT_PROCESS,
+ PW_STREAM_FLAG_RT_PROCESS |
+ PW_STREAM_FLAG_ASYNC,
params, n_params)) < 0) {
spa_pod_dynamic_builder_clean(&b);
return res;
--
GitLab

View File

@@ -0,0 +1,52 @@
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3600
https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/920beea3eb55ee7156bd8c00a201bdcafa0df5b0
From 920beea3eb55ee7156bd8c00a201bdcafa0df5b0 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Sun, 22 Oct 2023 17:26:25 +0200
Subject: [PATCH] alsa: guard agaist NULL areas
snd_pcm_ioplug_mmap_areas() can fail and return NULL
Fixes #3600
--- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c
+++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c
@@ -309,21 +309,21 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b,
xfer = nframes;
if (xfer > 0) {
const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io);
- const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
-
- if (io->stream == SND_PCM_STREAM_PLAYBACK)
- snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
- areas, offset,
- io->buffer_size,
- io->channels, xfer,
- io->format);
- else
- snd_pcm_areas_copy_wrap(areas, offset,
- io->buffer_size,
- pwareas, 0, nframes,
- io->channels, xfer,
- io->format);
-
+ if (areas != NULL) {
+ const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
+ if (io->stream == SND_PCM_STREAM_PLAYBACK)
+ snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
+ areas, offset,
+ io->buffer_size,
+ io->channels, xfer,
+ io->format);
+ else
+ snd_pcm_areas_copy_wrap(areas, offset,
+ io->buffer_size,
+ pwareas, 0, nframes,
+ io->channels, xfer,
+ io->format);
+ }
hw_ptr += xfer;
if (hw_ptr >= pw->boundary)
hw_ptr -= pw->boundary;
--
GitLab