summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 2ebfa9d2ef..4bd394ffda 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -863,18 +863,35 @@ static void handle_chapter_change(struct MPContext *mpctx)
// Execute a forceful refresh of the VO window, if it hasn't had a valid frame
// for a while. The problem is that a VO with no valid frame (vo->hasframe==0)
-// doesn't redraw video and doesn't OSD interaction. So screw it, hard.
+// doesn't redraw video and doesn't do OSD interaction. So screw it, hard.
// It also closes the VO if force_window or video display is not active.
-void handle_force_window(struct MPContext *mpctx, bool reconfig)
+int handle_force_window(struct MPContext *mpctx, bool reconfig)
{
// Don't interfere with real video playback
if (mpctx->d_video)
- return;
+ return 0;
- if (!mpctx->opts->force_vo && mpctx->video_out)
+ if (!mpctx->opts->force_vo) {
uninit_video_out(mpctx);
+ return 0;
+ }
- if (mpctx->video_out && (!mpctx->video_out->config_ok || reconfig)) {
+ if (!mpctx->video_out) {
+ struct vo_extra ex = {
+ .input_ctx = mpctx->input,
+ .osd = mpctx->osd,
+ .encode_lavc_ctx = mpctx->encode_lavc_ctx,
+ };
+ mpctx->video_out = init_best_video_out(mpctx->global, &ex);
+ if (!mpctx->video_out)
+ goto err;
+ mpctx->mouse_cursor_visible = true;
+ }
+
+ if (mpctx->opts->force_vo != 2 && !mpctx->playback_initialized)
+ return 0;
+
+ if (!mpctx->video_out->config_ok || reconfig) {
struct vo *vo = mpctx->video_out;
MP_INFO(mpctx, "Creating non-video VO window.\n");
// Pick whatever works
@@ -894,16 +911,21 @@ void handle_force_window(struct MPContext *mpctx, bool reconfig)
.w = w, .h = h,
.d_w = w, .d_h = h,
};
- if (vo_reconfig(vo, &p, 0) < 0) {
- mpctx->opts->force_vo = 0;
- uninit_video_out(mpctx);
- return;
- }
+ if (vo_reconfig(vo, &p, 0) < 0)
+ goto err;
vo_control(vo, VOCTRL_RESTORE_SCREENSAVER, NULL);
vo_set_paused(vo, true);
vo_redraw(vo);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
}
+
+ return 0;
+
+err:
+ mpctx->opts->force_vo = 0;
+ uninit_video_out(mpctx);
+ MP_FATAL(mpctx, "Error opening/initializing the VO window.\n");
+ return -1;
}
// Potentially needed by some Lua scripts, which assume TICK always comes.