From 745b7ee900fddcb65445b7965aabe3f4a7fa46ce Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 4 Dec 2020 15:10:52 +0100 Subject: [PATCH] pulse-server: tweak some parameters to get lower latency --- src/modules/module-protocol-pulse/defs.h | 2 +- src/modules/module-protocol-pulse/pulse-server.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/module-protocol-pulse/defs.h b/src/modules/module-protocol-pulse/defs.h index 07c89e1d9..3776658d4 100644 --- a/src/modules/module-protocol-pulse/defs.h +++ b/src/modules/module-protocol-pulse/defs.h @@ -42,7 +42,7 @@ #define MIN_BUFFERS 8u #define MAX_BUFFERS 64u -#define MIN_SAMPLES 24u +#define MIN_SAMPLES 16u #define MIN_USEC (MIN_SAMPLES * SPA_USEC_PER_SEC / 48000u) #define MAXLENGTH (4*1024*1024) /* 4MB */ diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 9f3fcc82b..e0554a343 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -954,6 +954,7 @@ static void fix_playback_buffer_attr(struct stream *s, struct buffer_attr *attr) uint32_t frame_size, max_prebuf, minreq; frame_size = s->frame_size; + minreq = usec_to_bytes_round_up(MIN_USEC, &s->ss); if (attr->maxlength == (uint32_t) -1 || attr->maxlength > MAXLENGTH) attr->maxlength = MAXLENGTH; @@ -966,8 +967,7 @@ static void fix_playback_buffer_attr(struct stream *s, struct buffer_attr *attr) attr->tlength = attr->maxlength; attr->tlength -= attr->tlength % frame_size; attr->tlength = SPA_MAX(attr->tlength, frame_size); - - s->missing = attr->tlength; + attr->tlength = SPA_MAX(attr->tlength, minreq); if (attr->minreq == (uint32_t) -1) { uint32_t process = usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*1000, &s->ss); @@ -977,7 +977,6 @@ static void fix_playback_buffer_attr(struct stream *s, struct buffer_attr *attr) m -= m % frame_size; attr->minreq = SPA_MIN(process, m); } - minreq = usec_to_bytes_round_up(MIN_USEC, &s->ss); attr->minreq = SPA_MAX(attr->minreq, minreq); if (attr->tlength < attr->minreq+frame_size) @@ -996,6 +995,7 @@ static void fix_playback_buffer_attr(struct stream *s, struct buffer_attr *attr) attr->prebuf = max_prebuf; attr->prebuf -= attr->prebuf % frame_size; + s->missing = attr->tlength; attr->fragsize = 0; pw_log_info(NAME" %p: [%s] maxlength:%u tlength:%u minreq:%u prebuf:%u", s, @@ -1248,7 +1248,7 @@ static const struct spa_pod *get_buffers_param(struct stream *s, stride = s->frame_size; if (s->direction == PW_DIRECTION_OUTPUT) { - maxsize = attr->tlength * 2; + maxsize = attr->tlength * 4; size = attr->minreq * 2; } else { size = attr->fragsize;