From b82e270abf5391afbb84f7fb678ae5ebe4a6eb13 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 10 Oct 2023 12:09:54 +0200 Subject: Account for enqueues while in cubeb_audio_dump_stream::write_all --- src/cubeb_audio_dump.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cubeb_audio_dump.cpp b/src/cubeb_audio_dump.cpp index 8de3d88..a290ff2 100644 --- a/src/cubeb_audio_dump.cpp +++ b/src/cubeb_audio_dump.cpp @@ -64,13 +64,10 @@ public: size_t write_all() { - int available = ringbuffer.available_read(); size_t written = 0; - while (available) { - const int buf_sz = 16 * 1024; - uint8_t buf[buf_sz]; - int rv = ringbuffer.dequeue(buf, buf_sz); - available -= rv; + const int buf_sz = 16 * 1024; + uint8_t buf[buf_sz]; + while (int rv = ringbuffer.dequeue(buf, buf_sz)) { written += fwrite(buf, rv, 1, file); } return written; -- cgit v1.2.3