ao_alsa: actually report underruns to user

Print them as a warning.

Note that there may be some cases where it underruns, without being a
bad condition. This could possibly happen e.g. if the last chunk is
written, and then it resumes playback some time after that. Eventually I
want to add more code to avoid such spurious warnings.
This commit is contained in:
wm4 2018-04-12 17:30:31 +02:00 committed by Jan Ekström
parent bd62d78854
commit 9ee9313465
1 changed files with 5 additions and 5 deletions

View File

@ -856,11 +856,6 @@ static int init_device(struct ao *ao, int mode)
(p->alsa, alsa_swparams, p->outburst);
CHECK_ALSA_ERROR("Unable to set start threshold");
/* disable underrun reporting */
err = snd_pcm_sw_params_set_stop_threshold
(p->alsa, alsa_swparams, boundary);
CHECK_ALSA_ERROR("Unable to set stop threshold");
/* play silence when there is an underrun */
err = snd_pcm_sw_params_set_silence_size
(p->alsa, alsa_swparams, boundary);
@ -1117,6 +1112,11 @@ static int play(struct ao *ao, void **data, int samples, int flags)
} else if (res < 0) {
if (res == -ESTRPIPE) { /* suspend */
resume_device(ao);
} else if (res == -EPIPE) {
// For some reason, writing a smaller fragment at the end
// immediately underruns.
if (!(flags & AOPLAY_FINAL_CHUNK))
MP_WARN(ao, "Device underrun detected.\n");
} else {
MP_ERR(ao, "Write error: %s\n", snd_strerror(res));
}