From 1e96f5bcd98f41fa11d87f1a5236468f985327a9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 27 Nov 2013 20:54:29 +0100 Subject: Move some code from player to audio/video reset functions --- audio/decode/dec_audio.c | 8 ++++++-- mpvcore/player/playloop.c | 9 --------- mpvcore/player/video.c | 2 -- video/decode/dec_video.c | 7 +++++++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 26452b702e..8cd7783069 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -349,8 +349,12 @@ int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf, void audio_reset_decoding(struct dec_audio *d_audio) { - d_audio->pts = MP_NOPTS_VALUE; - d_audio->pts_offset = 0; if (d_audio->ad_driver) d_audio->ad_driver->control(d_audio, ADCTRL_RESET, NULL); + if (d_audio->afilter) + af_control_all(d_audio->afilter, AF_CONTROL_RESET, NULL); + d_audio->pts = MP_NOPTS_VALUE; + d_audio->pts_offset = 0; + if (d_audio->decode_buffer) + mp_audio_buffer_clear(d_audio->decode_buffer); } diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c index d2c3904c77..650f164f05 100644 --- a/mpvcore/player/playloop.c +++ b/mpvcore/player/playloop.c @@ -172,12 +172,6 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao) if (mpctx->d_video) { video_reset_decoding(mpctx->d_video); vo_seek_reset(mpctx->video_out); - if (mpctx->d_video->vf_initialized == 1) - vf_chain_seek_reset(mpctx->d_video->vfilter); - mpctx->d_video->num_buffered_pts = 0; - mpctx->d_video->last_pts = MP_NOPTS_VALUE; - mpctx->d_video->last_packet_pdts = MP_NOPTS_VALUE; - mpctx->d_video->pts = MP_NOPTS_VALUE; mpctx->video_pts = MP_NOPTS_VALUE; mpctx->delay = 0; mpctx->time_frame = 0; @@ -185,11 +179,8 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao) if (mpctx->d_audio) { audio_reset_decoding(mpctx->d_audio); - if (mpctx->d_audio->afilter) - af_control_all(mpctx->d_audio->afilter, AF_CONTROL_RESET, NULL); if (reset_ao) clear_audio_output_buffers(mpctx); - clear_audio_decode_buffers(mpctx); } reset_subtitles(mpctx); diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index 65343cfa58..a9dffaf6e9 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -118,8 +118,6 @@ int reinit_video_chain(struct MPContext *mpctx) struct dec_video *d_video = talloc_zero(NULL, struct dec_video); mpctx->d_video = d_video; - d_video->last_pts = MP_NOPTS_VALUE; - d_video->last_packet_pdts = MP_NOPTS_VALUE; d_video->opts = mpctx->opts; d_video->header = sh; d_video->fps = sh->video->fps; diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 497ae56a02..b073173104 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -59,8 +59,14 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = { void video_reset_decoding(struct dec_video *d_video) { video_vd_control(d_video, VDCTRL_RESET, NULL); + if (d_video->vf_initialized == 1) + vf_chain_seek_reset(d_video->vfilter); d_video->prev_codec_reordered_pts = MP_NOPTS_VALUE; d_video->prev_sorted_pts = MP_NOPTS_VALUE; + d_video->num_buffered_pts = 0; + d_video->last_pts = MP_NOPTS_VALUE; + d_video->last_packet_pdts = MP_NOPTS_VALUE; + d_video->pts = MP_NOPTS_VALUE; } int video_vd_control(struct dec_video *d_video, int cmd, void *arg) @@ -165,6 +171,7 @@ static const struct vd_functions *find_driver(const char *name) bool video_init_best_codec(struct dec_video *d_video, char* video_decoders) { assert(!d_video->vd_driver); + video_reset_decoding(d_video); struct mp_decoder_entry *decoder = NULL; struct mp_decoder_list *list = -- cgit v1.2.3