From 9ee9313465ca49f2cfdd407797febed7692e1144 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Apr 2018 17:30:31 +0200 Subject: 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. --- audio/out/ao_alsa.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 3562634848..d8a1ec5cae 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -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)); } -- cgit v1.2.3