summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-06 20:13:28 +0200
committerwm4 <wm4@nowhere>2019-10-06 20:46:22 +0200
commite38b0b245ed4b12f71f0274e25275f301faf93a3 (patch)
tree40dbb5c48a009084e78ae5f789a6df3ae3536233
parent81e51a15f7e16d23216c7ab78502df245157723e (diff)
downloadmpv-e38b0b245ed4b12f71f0274e25275f301faf93a3.tar.bz2
mpv-e38b0b245ed4b12f71f0274e25275f301faf93a3.tar.xz
ao_alsa: don't silence legitimate underrun if final chunk underruns
It turns out that case 2) mentioned in the previous commit happened quite often when playback ended normally. There is probably a legitimate underrun with normal buffer sizes (100 ms, 4 fragments, gapless audio in "weak" mode). This is a result of the player waiting for video to end, and/or the time needed to kill the video window. The former case means that it depends on your test case whether it happens (a file where video ends slightly before audio is less likely to trigger it). This in turn is due to how gapless playback works. Achieving not having a "gap" requires queuing the audio of the next file without playing a partial chunk (as AOPLAY_FINAL_CHUNK would do). The partial chunk is then played as part of the first chunk played from the next file. But if it detects "later" that there is no next file, it still needs to get rid of the last fragment with AOPLAY_FINAL_CHUNK. At this point it's too late, and an underrun may have actually happened. The way the player uninits and reinits the entire playback engine for the next file in a "serial" manner means it cannot know in advance whether this works. This is the reason why the idiot who added the underrun exception for the last chunk in play() was wrong (I wrote that btw., before you accuse me of being rude). Yes, it's a real underrun, and you could probably hear it.
-rw-r--r--audio/out/ao_alsa.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 28294ccc13..dfbe9f1ceb 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -1121,10 +1121,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
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");
+ MP_WARN(ao, "Device underrun detected.\n");
} else {
MP_ERR(ao, "Write error: %s\n", snd_strerror(res));
}