From f1d161d55f458cf47e63d1ab9ddf08859019dd8a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 12 Aug 2017 23:08:48 +0200 Subject: player: make --lavfi-complex changeable at runtime Tends to be somewhat glitchy if subtitles are enabled, and you enable and disable tracks. On error, this will disable --lavfi-complex, which will result in whatever behavior. --- player/video.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index 414629c3c2..5d5f7f1fac 100644 --- a/player/video.c +++ b/player/video.c @@ -456,23 +456,20 @@ err_out: return 0; } -int reinit_video_chain(struct MPContext *mpctx) +void reinit_video_chain(struct MPContext *mpctx) { - return reinit_video_chain_src(mpctx, NULL); + struct track *track = mpctx->current_track[0][STREAM_VIDEO]; + if (!track || !track->stream) { + error_on_track(mpctx, track); + handle_force_window(mpctx, true); + return; + } + reinit_video_chain_src(mpctx, track); } -int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) +// (track=NULL creates a blank chain, used for lavfi-complex) +void reinit_video_chain_src(struct MPContext *mpctx, struct track *track) { - struct track *track = NULL; - struct sh_stream *sh = NULL; - if (!src) { - track = mpctx->current_track[0][STREAM_VIDEO]; - if (!track) - return 0; - sh = track->stream; - if (!sh) - goto no_video; - } assert(!mpctx->vo_chain); if (!mpctx->video_out) { @@ -504,11 +501,7 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) vo_c->hwdec_devs = vo_c->vo->hwdec_devs; - if (mpctx->lavfi) - lavfi_set_hwdec_devs(mpctx->lavfi, vo_c->hwdec_devs); - - vo_c->filter_src = src; - if (!vo_c->filter_src) { + if (track) { vo_c->track = track; track->vo_c = vo_c; if (!init_video_decoder(mpctx, track)) @@ -516,7 +509,7 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) vo_c->video_src = track->d_video; vo_c->container_fps = vo_c->video_src->fps; - vo_c->is_coverart = !!sh->attached_picture; + vo_c->is_coverart = !!track->stream->attached_picture; track->vo_c = vo_c; vo_c->track = track; @@ -540,14 +533,12 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) reset_video_state(mpctx); reset_subtitle_state(mpctx); - return 1; + return; err_out: -no_video: uninit_video_chain(mpctx); error_on_track(mpctx, track); handle_force_window(mpctx, true); - return 0; } // Try to refresh the video by doing a precise seek to the currently displayed -- cgit v1.2.3