From 2f4e01e772e894c42021cf15d7d6961ff145ff7e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Sep 2015 17:58:02 +0200 Subject: player: make force-window in auto-profiles actually work The previous commit was incomplete (and I didn't notice due to a broken test procedure). The annoying part is that actually creating the VO was separate; redo this and merge the code for this into handle_force_window() as well. This will also make implementing proper reaction to runtime option changes easier. (Only the part for actually listening to option changes is missing.) --- player/playloop.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'player/playloop.c') 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. -- cgit v1.2.3