Apply patches to fix openal delay and echo-cancel distortion

This commit is contained in:
Wim Taymans 2023-10-23 11:22:01 +02:00
parent f8d1040e50
commit 6f07b22f52
3 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From adb41c410a8b861f69bb7793e819b98a39eab586 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Fri, 20 Oct 2023 09:57:52 +0200
Subject: [PATCH 1/2] 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
---
src/pipewire/stream.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c
index 25051d64f..db2c3f7b7 100644
--- 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;
}
--
2.41.0

View File

@ -0,0 +1,40 @@
From 73ffb6cf7f3e82dd97038587cff138df54723b35 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Sat, 21 Oct 2023 09:27:43 +0200
Subject: [PATCH 2/2] 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
---
src/modules/module-echo-cancel.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/modules/module-echo-cancel.c b/src/modules/module-echo-cancel.c
index ae3934658..ab3698308 100644
--- 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;
--
2.41.0

View File

@ -9,7 +9,7 @@
%global ms_version 0.4.2
# For rpmdev-bumpspec and releng automation
%global baserelease 1
%global baserelease 2
#global snapdate 20210107
#global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb
@ -76,6 +76,8 @@ Source0: https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/%{ver
Source1: pipewire.sysusers
## upstream patches
Patch0001: 0001-stream-improve-queued_buffers-reporting.patch
Patch0002: 0002-module-echo-cancel-playback-and-source-are-async.patch
## upstreamable patches
@ -722,6 +724,9 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || :
%endif
%changelog
* Mon Oct 23 2023 Wim Taymans <wtaymans@redhat.com> - 0.3.83-2
- Apply patches to fix openal delay and echo-cancel distortion
* Thu Oct 19 2023 Wim Taymans <wtaymans@redhat.com> - 0.3.83-1
- Update version to 0.3.83