ALSA: fix sometimes calling write_callback with 0 frame_count_max

This commit is contained in:
Andrew Kelley 2015-09-02 10:24:04 -07:00
parent 1d2cf2ed59
commit 06dc7704a3
2 changed files with 4 additions and 3 deletions

View file

@ -62,7 +62,7 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
for (;;) { for (;;) {
int frame_count = frames_left; int frame_count = frames_left;
if ((err = soundio_outstream_begin_write(outstream, &areas, &frame_count))) { if ((err = soundio_outstream_begin_write(outstream, &areas, &frame_count))) {
fprintf(stderr, "%s\n", soundio_strerror(err)); fprintf(stderr, "unrecoverable stream error: %s\n", soundio_strerror(err));
exit(1); exit(1);
} }
@ -85,7 +85,7 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
if ((err = soundio_outstream_end_write(outstream))) { if ((err = soundio_outstream_end_write(outstream))) {
if (err == SoundIoErrorUnderflow) if (err == SoundIoErrorUnderflow)
return; return;
fprintf(stderr, "%s\n", soundio_strerror(err)); fprintf(stderr, "unrecoverable stream error: %s\n", soundio_strerror(err));
exit(1); exit(1);
} }

View file

@ -1091,7 +1091,8 @@ void outstream_thread_run(void *arg) {
continue; continue;
} }
outstream->write_callback(outstream, 0, avail); if (avail > 0)
outstream->write_callback(outstream, 0, avail);
continue; continue;
} }
case SND_PCM_STATE_XRUN: case SND_PCM_STATE_XRUN: