aboutsummaryrefslogtreecommitdiffhomepage
path: root/mpvcore/player/loadfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore/player/loadfile.c')
-rw-r--r--mpvcore/player/loadfile.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index a35da703ed..fffb1566c2 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -43,6 +43,8 @@
#include "mpvcore/input/input.h"
#include "audio/mixer.h"
+#include "audio/audio.h"
+#include "audio/audio_buffer.h"
#include "audio/decode/dec_audio.h"
#include "audio/out/ao.h"
#include "demux/demux.h"
@@ -163,11 +165,13 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
// Note: with gapless_audio, stop_play is not correctly set
if (opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) {
drain = true;
- int len = ao->buffer_playable_size;
- assert(len <= ao->buffer.len);
- int played = ao_play(ao, ao->buffer.start, len,
+ struct mp_audio data;
+ 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 < len)
+ if (played < samples)
MP_WARN(ao, "Audio output truncated at end.\n");
}
ao_uninit(ao, drain);