From 77f2fd97f89c93be6595dde29b86384047f05ba2 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 9 Aug 2021 08:51:50 -0500 Subject: [PATCH] command: merge window-scale code together Based on a small patch originally written by @avih. Instead of duplicating the window-scale logic in update_window_scale, just call the mp_property_current_window_scale function with the M_PROPERTY_SET action and a NULL property. --- player/command.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/player/command.c b/player/command.c index 02a008ef57..d703c39afe 100644 --- a/player/command.c +++ b/player/command.c @@ -2331,6 +2331,7 @@ static int mp_property_current_window_scale(void *ctx, struct m_property *prop, return M_PROPERTY_UNAVAILABLE; if (action == M_PROPERTY_SET) { + // Also called by update_window_scale as a NULL property. double scale = *(double *)arg; int s[2] = {vid_w * scale, vid_h * scale}; if (s[0] <= 0 || s[1] <= 0) @@ -2351,20 +2352,9 @@ static int mp_property_current_window_scale(void *ctx, struct m_property *prop, static void update_window_scale(struct MPContext *mpctx) { - struct vo *vo = mpctx->video_out; - if (!vo) - return; - - struct mp_image_params params = get_video_out_params(mpctx); - int vid_w, vid_h; - mp_image_params_get_dsize(¶ms, &vid_w, &vid_h); - if (vid_w < 1 || vid_h < 1) - return; - double scale = mpctx->opts->vo->window_scale; - int s[2] = {vid_w * scale, vid_h * scale}; - if (s[0] > 0 && s[1] > 0) - vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s); + mp_property_current_window_scale(mpctx, (struct m_property *)NULL, + M_PROPERTY_SET, (void*)&scale); } static int mp_property_display_fps(void *ctx, struct m_property *prop,