From aea7ace124a23836c313a2449a8a3ea5ef85942a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 20 Oct 2020 15:53:56 +0200 Subject: [PATCH] pulse-server: keep track of requested bytes Keep track of the amount of bytes we already requested from the client and don't ask for those again. Fixes initial hickups in firefox and others. --- src/modules/module-protocol-pulse/pulse-server.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 9fad26bd3..8a6644935 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -129,6 +129,7 @@ struct stream { uint64_t ticks_base; struct timeval timestamp; int64_t delay; + uint32_t pending; struct sample_spec ss; struct channel_map map; @@ -548,6 +549,7 @@ static inline uint32_t writable_size(const struct stream *s, uint64_t elapsed) queued = queued_size(s, elapsed); target = target_queue(s); + target -= SPA_MIN(target, s->pending); wanted = wanted_size(s, queued, target); required = required_size(s); @@ -616,6 +618,8 @@ static int send_command_request(struct stream *stream) TAG_U32, size, TAG_INVALID); + stream->pending += size; + return send_message(client, msg); } @@ -636,6 +640,8 @@ static int reply_create_playback_stream(struct stream *stream) TAG_U32, size, /* missing/requested bytes */ TAG_INVALID); + stream->pending = size; + if (client->version >= 9) { message_put(reply, TAG_U32, stream->attr.maxlength, @@ -2614,6 +2620,7 @@ static int handle_memblock(struct client *client, struct message *msg) spa_ringbuffer_write_update(&stream->ring, index + msg->length); stream->write_index += msg->length; + stream->pending -= SPA_MIN(stream->pending, msg->length); } res = 0; finish: