From d5680a119fe9abc70dd72761664701a4f8c46da2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 20 Nov 2020 14:56:23 +0100 Subject: [PATCH] pulse-server: Fix REQUEST missing bytes Also count the amount of underrun bytes as missing so that we request them from the client. Provide one fragment of minreq when we underrun instead of the full buffer size. Fixes #395 --- src/modules/module-protocol-pulse/pulse-server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 8a5c90af1..662b48f1c 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -989,9 +989,6 @@ static int reply_create_playback_stream(struct stream *stream) spa_ringbuffer_init(&stream->ring); - pw_log_info(NAME" %p: [%s] reply CREATE_PLAYBACK_STREAM tag:%u", stream, - client->name, stream->create_tag); - lat.num = stream->attr.minreq * 2 / stream->frame_size; lat.denom = stream->ss.rate; lat_usec = lat.num * SPA_USEC_PER_SEC / lat.denom; @@ -1004,6 +1001,9 @@ static int reply_create_playback_stream(struct stream *stream) size = stream_pop_missing(stream); + pw_log_info(NAME" %p: [%s] reply CREATE_PLAYBACK_STREAM tag:%u size:%u latency:%s", + stream, client->name, stream->create_tag, size, latency); + reply = reply_new(client, stream->create_tag); message_put(reply, TAG_U32, stream->channel, /* stream index/channel */ @@ -1324,7 +1324,7 @@ do_process_done(struct spa_loop *loop, else send_stream_started(stream); } - stream->missing += pd->playing_for; + stream->missing += pd->playing_for + pd->underrun_for; stream->playing_for += pd->playing_for; stream->underrun_for += pd->underrun_for; @@ -1393,7 +1393,7 @@ static void stream_process(void *data) int32_t avail = spa_ringbuffer_get_read_index(&stream->ring, &pd.read_index); if (avail <= 0) { /* underrun, produce a silence buffer */ - size = buf->datas[0].maxsize; + size = SPA_MIN(buf->datas[0].maxsize, stream->attr.minreq); memset(p, 0, size); if (stream->draining) {