dummy backend: fix sometimes calling write_callback with 0 avail

This commit is contained in:
Andrew Kelley 2015-09-11 10:24:30 -07:00
parent c62c2e4661
commit c3e3af2061

View file

@ -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_bytes = soundio_ring_buffer_capacity(&osd->ring_buffer) - fill_bytes;
int free_frames = free_bytes / outstream->bytes_per_frame; int free_frames = free_bytes / outstream->bytes_per_frame;
osd->frames_left = free_frames; 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(); double start_time = soundio_os_get_time();
long frames_consumed = 0; 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_bytes = soundio_ring_buffer_capacity(&osd->ring_buffer);
int free_frames = free_bytes / outstream->bytes_per_frame; int free_frames = free_bytes / outstream->bytes_per_frame;
osd->frames_left = free_frames; 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; frames_consumed = 0;
start_time = soundio_os_get_time(); start_time = soundio_os_get_time();
continue; continue;
@ -59,7 +61,8 @@ static void playback_thread_run(void *arg) {
if (frames_to_kill > fill_frames) { if (frames_to_kill > fill_frames) {
outstream->underflow_callback(outstream); outstream->underflow_callback(outstream);
osd->frames_left = free_frames; 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; frames_consumed = 0;
start_time = soundio_os_get_time(); start_time = soundio_os_get_time();
} else if (free_frames > 0) { } else if (free_frames > 0) {