From 0fee7c1b37ba9ae6f0b510ffcb27a7dbe1ce70df Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 3 Mar 2025 22:35:08 -0600 Subject: [PATCH] command: wait until MPV_EVENT_VIDEO_RECONFIG to pretty print hwdec It's not actually possible to truly know the hwdec-current value until after this event is successfully signalled. Add some special handling to the pretty printing of hwdec to delay it until we get the video reconfig event in command_event and then do the pretty print there if appropriate. --- player/command.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/player/command.c b/player/command.c index 21b177e4e5..62cbea4c5c 100644 --- a/player/command.c +++ b/player/command.c @@ -118,6 +118,8 @@ struct command_ctx { mpv_node udata; mpv_node mdata; + int hwdec_osd_mode; + double cached_window_scale; }; @@ -4747,10 +4749,17 @@ static void show_property_osd(MPContext *mpctx, const char *name, int osd_mode) { struct MPOpts *opts = mpctx->opts; struct property_osd_display disp = {.name = name, .osd_name = name}; + struct command_ctx *cmd = mpctx->command_ctx; if (!osd_mode) return; + // hwdec is a special case that must wait until video reconfig + if (strcmp(name, "hwdec") == 0 && !cmd->hwdec_osd_mode) { + cmd->hwdec_osd_mode = osd_mode; + return; + } + // look for the command for (const struct property_osd_display *p = property_osd_display; p->name; p++) { @@ -7593,6 +7602,11 @@ static void command_event(struct MPContext *mpctx, int event, void *arg) run_command_opts(mpctx); } + if (event == MPV_EVENT_VIDEO_RECONFIG && ctx->hwdec_osd_mode) { + show_property_osd(mpctx, "hwdec", ctx->hwdec_osd_mode); + ctx->hwdec_osd_mode = 0; + } + if (event == MPV_EVENT_IDLE) run_command_opts(mpctx);