diff options
-rw-r--r-- | DOCS/man/en/input.rst | 6 | ||||
-rw-r--r-- | player/audio.c | 4 | ||||
-rw-r--r-- | player/video.c | 18 |
3 files changed, 22 insertions, 6 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 6fe4c90759..a1e4ee45e3 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -332,6 +332,12 @@ Input Commands that are Possibly Subject to Change ``show_text ${vf}``. Note that auto-inserted filters for format conversion are not shown on the list, only what was requested by the user. + Normally, the commands will check whether the video chain is recreated + successfully, and will undo the operation on failure. If the command is run + before video is configured (can happen if the command is run immediately + after opening a file and before a video frame is decoded), this check can't + be run. Then it can happen that creating the video chain fails. + .. admonition:: Example for input.conf - ``a vf set flip`` turn video upside-down on the ``a`` key diff --git a/player/audio.c b/player/audio.c index 65c4ad74dd..12d03689eb 100644 --- a/player/audio.c +++ b/player/audio.c @@ -88,7 +88,7 @@ int reinit_audio_filters(struct MPContext *mpctx) { struct dec_audio *d_audio = mpctx->d_audio; if (!d_audio) - return -2; + return 0; af_uninit(mpctx->d_audio->afilter); if (af_init(mpctx->d_audio->afilter) < 0) @@ -96,7 +96,7 @@ int reinit_audio_filters(struct MPContext *mpctx) if (recreate_audio_filters(mpctx) < 0) return -1; - return 0; + return 1; } void reinit_audio_chain(struct MPContext *mpctx) diff --git a/player/video.c b/player/video.c index 39a5b55a2a..8119c40c98 100644 --- a/player/video.c +++ b/player/video.c @@ -140,13 +140,19 @@ int reinit_video_filters(struct MPContext *mpctx) { struct dec_video *d_video = mpctx->d_video; - if (!d_video || !d_video->decoder_output.imgfmt) - return -2; + if (!d_video) + return 0; + bool need_reconfig = d_video->vfilter->initialized != 0; recreate_video_filters(mpctx); - reconfig_video(mpctx, &d_video->decoder_output, true); - return d_video->vfilter && d_video->vfilter->initialized > 0 ? 0 : -1; + if (need_reconfig) + reconfig_video(mpctx, &d_video->decoder_output, true); + + if (!d_video->vfilter) + return 0; + + return d_video->vfilter->initialized; } int reinit_video_chain(struct MPContext *mpctx) @@ -246,6 +252,10 @@ no_video: void mp_force_video_refresh(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; + struct dec_video *d_video = mpctx->d_video; + + if (!d_video || !d_video->decoder_output.imgfmt) + return; // If not paused, the next frame should come soon enough. if (opts->pause && mpctx->last_vo_pts != MP_NOPTS_VALUE) |