output/alsa: throw on snd_pcm_writei() error while draining

This implements real error handling, and avoids calling
CancelInternal() from this code path.
This commit is contained in:
Max Kellermann 2018-11-14 10:08:29 +01:00
parent 7f143a83c1
commit 1a43f5145d
1 changed files with 6 additions and 3 deletions

View File

@ -727,9 +727,12 @@ AlsaOutput::DrainInternal()
/* drain period_buffer */
if (!period_buffer.IsEmpty()) {
auto frames_written = WriteFromPeriodBuffer();
if (frames_written < 0 && frames_written != -EAGAIN) {
CancelInternal();
return true;
if (frames_written < 0) {
if (frames_written == -EAGAIN)
return false;
throw FormatRuntimeError("snd_pcm_writei() failed: %s",
snd_strerror(-frames_written));
}
if (!period_buffer.IsEmpty())