summaryrefslogtreecommitdiffstats
path: root/mpvcore/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-08 20:00:58 +0100
committerwm4 <wm4@nowhere>2013-11-08 20:00:58 +0100
commit8125252399d9b02a6f143d109a92341ff7eff5a9 (patch)
tree3b9fed7c1acadca63714c29d39fda681f0dda33a /mpvcore/player/playloop.c
parent052a7d54ab4efbf9743767ea7aae95c98f5b5379 (diff)
downloadmpv-8125252399d9b02a6f143d109a92341ff7eff5a9.tar.bz2
mpv-8125252399d9b02a6f143d109a92341ff7eff5a9.tar.xz
audio: don't let ao_lavc access frontend internals, change gapless audio
ao_lavc.c accesses ao->buffer, which I consider internal. The access was done in ao_lavc.c/uninit(), which tried to get the left-over audio in order to write the last (possibly partial) audio frame. The play() function didn't accept partial frames, because the AOPLAY_FINAL_CHUNK flag was not correctly set, and handling it otherwise would require an internal FIFO. Fix this by making sure that with gapless audio (used with encoding), the AOPLAY_FINAL_CHUNK is set only once, instead when each file ends. Basically, move the hack in ao_lavc's uninit to uninit_player. One thing can not be entirely correctly handled: if gapless audio is active, we don't know really whether the AO is closed because the file ended playing (i.e. we want to send the buffered remainder of the audio to the AO), or whether the user is quitting the player. (The stop_play flag is overwritten, fixing that is perhaps not worth it.) Handle this by adding additional code to drain the AO and the buffers when playback is quit (see play_current_file() change). Test case: mpv avdevice://lavfi:sine=441 avdevice://lavfi:sine=441 -length 0.2267 -gapless-audio
Diffstat (limited to 'mpvcore/player/playloop.c')
-rw-r--r--mpvcore/player/playloop.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c
index d4db03c446..6cd53214a2 100644
--- a/mpvcore/player/playloop.c
+++ b/mpvcore/player/playloop.c
@@ -254,10 +254,12 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
if (demuxer_amount == -1) {
assert(!need_reset);
mpctx->stop_play = AT_END_OF_FILE;
- // Clear audio from current position
if (mpctx->sh_audio && !timeline_fallthrough) {
+ // Seek outside of the file -> clear audio from current position
ao_reset(mpctx->ao);
mpctx->sh_audio->a_buffer_len = 0;
+ mpctx->ao->buffer.len = 0;
+ mpctx->ao->buffer_playable_size = 0;
}
return -1;
}