summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/player/audio.c17
-rw-r--r--mpvcore/player/loadfile.c8
-rw-r--r--mpvcore/player/mp_core.h2
-rw-r--r--mpvcore/player/playloop.c11
4 files changed, 25 insertions, 13 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;
+}
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index 569532840c..a35da703ed 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -1292,12 +1292,8 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
if (mpctx->stop_play == KEEP_PLAYING)
mpctx->stop_play = AT_END_OF_FILE;
- // Drop audio left in the buffers
- if (mpctx->stop_play != AT_END_OF_FILE && mpctx->ao) {
- mpctx->ao->buffer_playable_size = 0;
- mpctx->ao->buffer.len = 0;
- ao_reset(mpctx->ao);
- }
+ if (mpctx->stop_play != AT_END_OF_FILE)
+ clear_audio_output_buffers(mpctx);
if (opts->position_save_on_quit && mpctx->stop_play == PT_QUIT)
mp_write_watch_later_conf(mpctx);
diff --git a/mpvcore/player/mp_core.h b/mpvcore/player/mp_core.h
index 05909543f4..3f20f9ab2e 100644
--- a/mpvcore/player/mp_core.h
+++ b/mpvcore/player/mp_core.h
@@ -330,6 +330,8 @@ int reinit_audio_filters(struct MPContext *mpctx);
double playing_audio_pts(struct MPContext *mpctx);
int fill_audio_out_buffers(struct MPContext *mpctx, double endpts);
double written_audio_pts(struct MPContext *mpctx);
+void clear_audio_output_buffers(struct MPContext *mpctx);
+void clear_audio_decode_buffers(struct MPContext *mpctx);
// configfiles.c
bool mp_parse_cfgfiles(struct MPContext *mpctx);
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c
index 6cd53214a2..9d5b4a5e25 100644
--- a/mpvcore/player/playloop.c
+++ b/mpvcore/player/playloop.c
@@ -185,9 +185,8 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac)
if (mpctx->sh_audio && reset_ac) {
resync_audio_stream(mpctx->sh_audio);
if (reset_ao)
- ao_reset(mpctx->ao);
- mpctx->ao->buffer.len = mpctx->ao->buffer_playable_size;
- mpctx->sh_audio->a_buffer_len = 0;
+ clear_audio_output_buffers(mpctx);
+ clear_audio_decode_buffers(mpctx);
}
reset_subtitles(mpctx);
@@ -256,10 +255,8 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
mpctx->stop_play = AT_END_OF_FILE;
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;
+ clear_audio_decode_buffers(mpctx);
+ clear_audio_output_buffers(mpctx);
}
return -1;
}