Add patch to fix ffmpeg capture and other stutterings.

This commit is contained in:
Wim Taymans 2022-09-22 15:33:08 +02:00
parent 0d37342097
commit ec8e19b6bb
3 changed files with 64 additions and 35 deletions

View File

@ -0,0 +1,59 @@
From b5024f4efbc7277422201a37f6b62b462ee648eb Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Mon, 19 Sep 2022 14:45:11 +0200
Subject: [PATCH] pulse-server: limit capture blocks to fragsize
Rename MAX_FRAGSIZE to MAX_BLOCK because it does not really limit the
fragsize, just the amount of data we can send in one block.
Don't send larger chunks than the fragsize. Some clients don't like
this. Also checked with #2418.
Fixes #2711, #2715
---
src/modules/module-protocol-pulse/pulse-server.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c
index b403aba21..636da0d97 100644
--- a/src/modules/module-protocol-pulse/pulse-server.c
+++ b/src/modules/module-protocol-pulse/pulse-server.c
@@ -89,7 +89,7 @@
#define MAX_FORMATS 32
/* The max amount of data we send in one block when capturing. In PulseAudio this
* size is derived from the mempool PA_MEMPOOL_SLOT_SIZE */
-#define MAX_FRAGSIZE (64*1024)
+#define MAX_BLOCK (64*1024)
#define TEMPORARY_MOVE_TIMEOUT (SPA_NSEC_PER_SEC)
@@ -681,13 +681,13 @@ static uint64_t fix_record_buffer_attr(struct stream *s, struct buffer_attr *att
attr->tlength = attr->minreq = attr->prebuf = 0;
- /* make sure can queue at least to fragsize without overruns */
+ /* make sure we can queue at least to fragsize without overruns */
if (attr->maxlength < attr->fragsize * 4)
attr->maxlength = attr->fragsize * 4;
- latency = attr->fragsize / frame_size;
+ latency = attr->fragsize;
- lat->num = latency;
+ lat->num = latency / frame_size;
lat->denom = rate;
clamp_latency(s, lat);
@@ -1341,7 +1341,8 @@ do_process_done(struct spa_loop *loop,
pw_log_trace("avail:%d index:%u", avail, index);
while ((uint32_t)avail >= stream->attr.fragsize) {
- towrite = SPA_MIN(avail, MAX_FRAGSIZE);
+ towrite = SPA_MIN(avail, MAX_BLOCK);
+ towrite = SPA_MIN(towrite, stream->attr.fragsize);
towrite = SPA_ROUND_DOWN(towrite, stream->frame_size);
msg = message_alloc(impl, stream->channel, towrite);
--
2.37.3

View File

@ -1,33 +0,0 @@
From d1cd199f16ff4741c765d604977f7b3e59ea68d4 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Mon, 19 Sep 2022 14:45:11 +0200
Subject: [PATCH] pulse-server: set record latency as fragsize / 2
The record latency is set to fragsize / 2 by pulseaudio, so do the
same in pipewire.
Fixes #2702
---
src/modules/module-protocol-pulse/pulse-server.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c
index b403aba21..32733f369 100644
--- a/src/modules/module-protocol-pulse/pulse-server.c
+++ b/src/modules/module-protocol-pulse/pulse-server.c
@@ -685,9 +685,10 @@ static uint64_t fix_record_buffer_attr(struct stream *s, struct buffer_attr *att
if (attr->maxlength < attr->fragsize * 4)
attr->maxlength = attr->fragsize * 4;
- latency = attr->fragsize / frame_size;
+ /* pulseaudio configures half the fragsize as latency in the source. */
+ latency = attr->fragsize / 2;
- lat->num = latency;
+ lat->num = latency / frame_size;
lat->denom = rate;
clamp_latency(s, lat);
--
2.37.3

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
@ -80,7 +80,7 @@ Source1: https://gitlab.freedesktop.org/pipewire/media-session/-/archive/
%endif
## upstream patches
Patch0001: 0001-pulse-server-set-record-latency-as-fragsize-2.patch
Patch0001: 0001-pulse-server-limit-capture-blocks-to-fragsize.patch
## upstreamable patches
@ -625,6 +625,9 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || :
%endif
%changelog
* Thu Sep 22 2022 Wim Taymans <wtaymans@redhat.com> - 0.3.58-3
- Add patch to fix ffmpeg capture and other stutterings.
* Mon Sep 19 2022 Wim Taymans <wtaymans@redhat.com> - 0.3.58-2
- Add patch to fix stuttering in Teamspeak.