diff options
author | wm4 <wm4@nowhere> | 2013-11-08 20:02:09 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-08 20:29:26 +0100 |
commit | 6354a6b07dd3e0aee23e71ee2574754d620bdd09 (patch) | |
tree | 2cd4137ddec69890434273774d4571786668e9e2 /mpvcore/player/audio.c | |
parent | 8125252399d9b02a6f143d109a92341ff7eff5a9 (diff) | |
download | mpv-6354a6b07dd3e0aee23e71ee2574754d620bdd09.tar.bz2 mpv-6354a6b07dd3e0aee23e71ee2574754d620bdd09.tar.xz |
player: factor audio buffer clearing code
Note that the change in seek_reset is not entirely equivalent: we even
drop the remainder of buffered audio when seeking. This should be more
correct, because the whole point of the reset_ao parameter is to control
whether audio queued for output should be dropped or not.
Diffstat (limited to 'mpvcore/player/audio.c')
-rw-r--r-- | mpvcore/player/audio.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mpvcore/player/audio.c b/mpvcore/player/audio.c index 2c3d044c41..a0c558f02a 100644 --- a/mpvcore/player/audio.c +++ b/mpvcore/player/audio.c @@ -421,3 +421,20 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) return signal_eof ? -2 : -partial_fill; } + +// Drop data queued for output, or which the AO is currently outputting. +void clear_audio_output_buffers(struct MPContext *mpctx) +{ + if (mpctx->ao) { + ao_reset(mpctx->ao); + mpctx->ao->buffer.len = 0; + mpctx->ao->buffer_playable_size = 0; + } +} + +// Drop decoded data queued for filtering. +void clear_audio_decode_buffers(struct MPContext *mpctx) +{ + if (mpctx->sh_audio) + mpctx->sh_audio->a_buffer_len = 0; +} |