From d3e74a49e7f5548d09c168153c25e664f8dcda49 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 14 Dec 2021 15:42:19 +0100 Subject: [PATCH] pulse-server: increase buffer size Because we keep everything in a ringbuffer and provide exactly the required amount of data, we can use 1/4 buffers. Also increase the buffer size. We don't want to limit the buffer size to the negotiated tlength because it can be increased later. Instead scale it to the max quantum size (8192) with a max resample rate of 32. --- src/modules/module-protocol-pulse/defs.h | 4 ++-- src/modules/module-protocol-pulse/pulse-server.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/module-protocol-pulse/defs.h b/src/modules/module-protocol-pulse/defs.h index bded84956..8a9756a2d 100644 --- a/src/modules/module-protocol-pulse/defs.h +++ b/src/modules/module-protocol-pulse/defs.h @@ -49,8 +49,8 @@ #define NATIVE_COOKIE_LENGTH 256 #define MAX_TAG_SIZE (64*1024) -#define MIN_BUFFERS 8u -#define MAX_BUFFERS 64u +#define MIN_BUFFERS 1u +#define MAX_BUFFERS 4u #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 22cb477f5..6e114c4b0 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1005,12 +1005,11 @@ static const struct spa_pod *get_buffers_param(struct stream *s, blocks = 1; stride = s->frame_size; + maxsize = 8192 * 32 * s->frame_size; if (s->direction == PW_DIRECTION_OUTPUT) { - maxsize = attr->tlength * s->frame_size; - size = attr->minreq * s->frame_size; + size = attr->minreq; } else { size = attr->fragsize; - maxsize = attr->fragsize * MAX_BUFFERS; } buffers = SPA_CLAMP(maxsize / size, MIN_BUFFERS, MAX_BUFFERS); @@ -1019,7 +1018,8 @@ static const struct spa_pod *get_buffers_param(struct stream *s, param = spa_pod_builder_add_object(b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, - SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(buffers, MIN_BUFFERS, MAX_BUFFERS), + SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(buffers, + MIN_BUFFERS, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(blocks), SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( size, size, maxsize),