From cc52a0340195b6062dbe7ec2c90c717d34101996 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 13 Feb 2020 13:24:11 +0100 Subject: audio: slightly simplify pull underrun message printing A previous commit moved the underrun reporting to report_underruns(), and called it from get_space(). One reason was that I worried about printing a log message from a "realtime" callback, so I tried to move it out of the way. (Though there's little justification other than a bad feeling. While an older version of the pull code tried to avoid any mutexes at all in the callback to accommodate "requirements" from APIs like jackaudio, we gave up on that. Nobody has complained yet.) Simplify this and move underrun reporting back to the callback. But instead of printing the message from there, move the message into the playloop. Change the message slightly, because ao->log is inaccessible, and without the log prefix (e.g. "[ao/alsa]"), some context is missing. --- player/audio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'player/audio.c') diff --git a/player/audio.c b/player/audio.c index 4f4b1992ae..fdc07fbf2b 100644 --- a/player/audio.c +++ b/player/audio.c @@ -859,8 +859,11 @@ void fill_audio_out_buffers(struct MPContext *mpctx) int playsize = ao_get_space(mpctx->ao); - if (ao_query_and_reset_events(mpctx->ao, AO_EVENT_UNDERRUN)) + if (ao_query_and_reset_events(mpctx->ao, AO_EVENT_UNDERRUN)) { + if (!ao_c->underrun) + MP_WARN(mpctx, "Audio device underrun detected.\n"); ao_c->underrun = true; + } // Stop feeding data if an underrun happened. Something else needs to // "unblock" audio after underrun. handle_update_cache() does this and can -- cgit v1.2.3