From c3e3af2061f90d1e3a9d1162c7f192aa105bbf31 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 11 Sep 2015 10:24:30 -0700 Subject: [PATCH] dummy backend: fix sometimes calling write_callback with 0 avail --- src/dummy.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dummy.cpp b/src/dummy.cpp index 9b81c56..2383f7b 100644 --- a/src/dummy.cpp +++ b/src/dummy.cpp @@ -21,7 +21,8 @@ static void playback_thread_run(void *arg) { int free_bytes = soundio_ring_buffer_capacity(&osd->ring_buffer) - fill_bytes; int free_frames = free_bytes / outstream->bytes_per_frame; osd->frames_left = free_frames; - outstream->write_callback(outstream, 0, free_frames); + if (free_frames > 0) + outstream->write_callback(outstream, 0, free_frames); double start_time = soundio_os_get_time(); long frames_consumed = 0; @@ -37,7 +38,8 @@ static void playback_thread_run(void *arg) { int free_bytes = soundio_ring_buffer_capacity(&osd->ring_buffer); int free_frames = free_bytes / outstream->bytes_per_frame; osd->frames_left = free_frames; - outstream->write_callback(outstream, 0, free_frames); + if (free_frames > 0) + outstream->write_callback(outstream, 0, free_frames); frames_consumed = 0; start_time = soundio_os_get_time(); continue; @@ -59,7 +61,8 @@ static void playback_thread_run(void *arg) { if (frames_to_kill > fill_frames) { outstream->underflow_callback(outstream); osd->frames_left = free_frames; - outstream->write_callback(outstream, 0, free_frames); + if (free_frames > 0) + outstream->write_callback(outstream, 0, free_frames); frames_consumed = 0; start_time = soundio_os_get_time(); } else if (free_frames > 0) {