From 8438c557cff37bd5861a9fd8e94941aba7e22aaf Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 17 Nov 2013 16:10:28 +0100 Subject: player: write final audo chunk only if there is audio left Don't call ao_play() if there's nothing left. Of course this still asks the AO to play internally buffered audio by setting drain=true. --- mpvcore/player/loadfile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c index 0c40f34900..f787b5e495 100644 --- a/mpvcore/player/loadfile.c +++ b/mpvcore/player/loadfile.c @@ -169,10 +169,12 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) mp_audio_buffer_peek(ao->buffer, &data); int samples = ao->buffer_playable_samples; assert(samples <= data.samples); - int played = ao_play(ao, data.planes, samples, - AOPLAY_FINAL_CHUNK); - if (played < samples) - MP_WARN(ao, "Audio output truncated at end.\n"); + if (samples > 0) { + int played = ao_play(ao, data.planes, samples, + AOPLAY_FINAL_CHUNK); + if (played < samples) + MP_WARN(ao, "Audio output truncated at end.\n"); + } } ao_uninit(ao, drain); } -- cgit v1.2.3