From 7bddb80c93a143bab66271c92b4e6f1f6d25c3bf Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Mar 2023 10:13:43 +0200 Subject: [PATCH] pulse-server: improve Buffer param We need to be able to fill up one quantum of data when the stream requests it so suggest a quantum_limit buffer size. Normally, the converter will further improve the buffer size parameters when resampling is involved but this is a good default for when working in passthrough mode. We don't actually use the stream buffering features so we're happy with just 1 or 2 buffers. --- .../module-protocol-pulse/pulse-server.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 3beb0f56c..e4711154b 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1154,30 +1154,25 @@ static const struct spa_pod *get_buffers_param(struct stream *s, struct buffer_attr *attr, struct spa_pod_builder *b) { const struct spa_pod *param; - uint32_t blocks, buffers, size, maxsize, stride; + uint32_t blocks, size, stride; struct defs *defs = &s->impl->defs; blocks = 1; stride = s->frame_size; - maxsize = defs->quantum_limit * 32 * s->frame_size; - if (s->direction == PW_DIRECTION_OUTPUT) { - size = attr->minreq; - } else { - size = attr->fragsize; - } - buffers = SPA_CLAMP(maxsize / size, MIN_BUFFERS, MAX_BUFFERS); + size = defs->quantum_limit * s->frame_size; - pw_log_info("[%s] stride %d maxsize %d size %u buffers %d", s->client->name, - stride, maxsize, size, buffers); + pw_log_info("[%s] stride %d size %u", s->client->name, stride, size); param = spa_pod_builder_add_object(b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, - SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(buffers, + SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, MIN_BUFFERS, MAX_BUFFERS), SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(blocks), SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int( - size, size, maxsize), + size, + 16 * s->frame_size, + INT32_MAX), SPA_PARAM_BUFFERS_stride, SPA_POD_Int(stride)); return param; }