From e3bd668ebd5f669e5f7d109191c87c678b569bb7 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 23 Apr 2010 20:14:59 +0300 Subject: Move seek-reset functionality out of demuxer.c Move code for resetting decoders after seeks, chapter seeks and angle changes out of demuxer.c. This functionality belongs on a higher level; the demux layer can't always know what kind of reinitialization is required. --- mplayer.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index c2596850b6..34c6d6dcd5 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2741,7 +2741,9 @@ static int seek(MPContext *mpctx, double amount, int style) if (mpctx->sh_video) { current_module = "seek_video_reset"; resync_video_stream(mpctx->sh_video); + mpctx->sh_video->timer = 0; vo_seek_reset(mpctx->video_out); + mpctx->sh_video->timer = 0; mpctx->sh_video->num_buffered_pts = 0; mpctx->sh_video->last_pts = MP_NOPTS_VALUE; mpctx->delay = 0; @@ -2759,6 +2761,7 @@ static int seek(MPContext *mpctx, double amount, int style) if (mpctx->sh_audio) { current_module = "seek_audio_reset"; + resync_audio_stream(mpctx->sh_audio); mpctx->audio_out->reset(); // stop audio, throwing away buffered data mpctx->sh_audio->a_buffer_len = 0; mpctx->sh_audio->a_out_buffer_len = 0; @@ -2806,9 +2809,21 @@ char *chapter_display_name(struct MPContext *mpctx, int chapter) int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts, char **chapter_name) { - if (!mpctx->chapters || !mpctx->sh_video) - return demuxer_seek_chapter(mpctx->demuxer, chapter, seek_pts, - chapter_name); + if (!mpctx->chapters || !mpctx->sh_video) { + int res = demuxer_seek_chapter(mpctx->demuxer, chapter, seek_pts, + chapter_name); + if (res >= 0) { + struct sh_video *sh_video = mpctx->demuxer->video->sh; + if (sh_video) + resync_video_stream(sh_video); + + struct sh_audio *sh_audio = mpctx->demuxer->audio->sh; + if (sh_audio) + resync_audio_stream(sh_audio); + } + return res; + } + if (chapter >= mpctx->num_chapters) return -1; if (chapter < 0) -- cgit v1.2.3