From 748e2054534740820cdd04db44009261316fcd2b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 2 Feb 2021 10:42:34 +0100 Subject: [PATCH] pulse-server: hand out silence when corked In the corked state we simply hand out silence and don't try to consume data from our ringbuffer. Also set the corked state before syncing this with the data thread. Fixes #662 --- src/modules/module-protocol-pulse/pulse-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 7b6846af8..bb384199f 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1559,7 +1559,7 @@ static void stream_process(void *data) else minreq = SPA_MAX(stream->minblock, stream->attr.minreq); - if (avail < (int32_t)minreq) { + if (avail < (int32_t)minreq || stream->corked) { /* underrun, produce a silence buffer */ size = SPA_MIN(buf->datas[0].maxsize, minreq); memset(p, 0, size); @@ -1571,7 +1571,7 @@ static void stream_process(void *data) pd.underrun_for = size; pd.underrun = true; } - if (stream->attr.prebuf == 0) { + if (stream->attr.prebuf == 0 && !stream->corked) { pd.missing = size; pd.playing_for = size; pd.read_index += size; @@ -2685,8 +2685,8 @@ static int do_cork_stream(struct client *client, uint32_t command, uint32_t tag, if (stream == NULL || stream->type == STREAM_TYPE_UPLOAD) return -ENOENT; - pw_stream_set_active(stream->stream, !cork); stream->corked = cork; + pw_stream_set_active(stream->stream, !cork); if (cork) { stream->is_underrun = true; } else {