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.
This commit is contained in:
wm4 2013-11-17 16:10:28 +01:00
parent e403140201
commit 8438c557cf
1 changed files with 6 additions and 4 deletions

View File

@ -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);
}