Skip to content

Commit

Permalink
m_option: add UPDATE_VO flag
Browse files Browse the repository at this point in the history
This will allow reiniting the VO when more options are changed without
hardcoding them in options.c

Also reinit the VO when changing --gpu-debug and --gpu-sw.
  • Loading branch information
guidocella authored and Dudemanguy committed Jul 24, 2024
1 parent d384a6b commit a5937ac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
11 changes: 6 additions & 5 deletions options/m_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,23 +457,24 @@ char *format_file_size(int64_t size);
#define UPDATE_SUB_HARD (1 << 22) // subtitle opts. that need full reinit
#define UPDATE_SUB_EXTS (1 << 23) // update internal list of sub exts
#define UPDATE_VIDEO (1 << 24) // force redraw if needed
#define UPDATE_OPT_LAST (1 << 24)
#define UPDATE_VO (1 << 25) // reinit the VO
#define UPDATE_OPT_LAST (1 << 25)

// All bits between _FIRST and _LAST (inclusive)
#define UPDATE_OPTS_MASK \
(((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1))

// type_float/type_double: string "default" is parsed as NaN (and reverse)
#define M_OPT_DEFAULT_NAN (1 << 25)
#define M_OPT_DEFAULT_NAN (1 << 26)

// type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected)
#define M_OPT_ALLOW_NO (1 << 26)
#define M_OPT_ALLOW_NO (1 << 27)

// type channels: disallow "auto" (still accept ""), limit list to at most 1 item.
#define M_OPT_CHANNELS_LIMITED (1 << 27)
#define M_OPT_CHANNELS_LIMITED (1 << 28)

// type_float/type_double: controls if pretty print should trim trailing zeros
#define M_OPT_FIXED_LEN_PRINT (1 << 28)
#define M_OPT_FIXED_LEN_PRINT (1 << 29)

// Like M_OPT_TYPE_OPTIONAL_PARAM.
#define M_OPT_OPTIONAL_PARAM (1 << 30)
Expand Down
2 changes: 1 addition & 1 deletion options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static const struct m_sub_options screenshot_conf = {
#define OPT_BASE_STRUCT struct mp_vo_opts

static const m_option_t mp_vo_opt_list[] = {
{"vo", OPT_SETTINGSLIST(video_driver_list, &vo_obj_list)},
{"vo", OPT_SETTINGSLIST(video_driver_list, &vo_obj_list), .flags = UPDATE_VO},
{"taskbar-progress", OPT_BOOL(taskbar_progress)},
{"drag-and-drop", OPT_CHOICE(drag_and_drop, {"no", -2}, {"auto", -1},
{"replace", DND_REPLACE},
Expand Down
5 changes: 1 addition & 4 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "options/m_config_frontend.h"
#include "options/parse_configfile.h"
#include "osdep/getpid.h"
#include "video/out/gpu/context.h"
#include "video/out/vo.h"
#include "video/csputils.h"
#include "video/hwdec.h"
Expand Down Expand Up @@ -7380,9 +7379,7 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
}

if (opt_ptr == &opts->vo->video_driver_list ||
opt_ptr == &opts->ra_ctx_opts->context_list ||
opt_ptr == &opts->ra_ctx_opts->context_type_list) {
if (flags & UPDATE_VO) {
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
uninit_video_out(mpctx);
handle_force_window(mpctx, true);
Expand Down
1 change: 1 addition & 0 deletions video/out/gpu/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const struct m_sub_options ra_ctx_conf = {
{0}
},
.size = sizeof(struct ra_ctx_opts),
.change_flags = UPDATE_VO,
};

static struct ra_ctx *create_in_contexts(struct vo *vo, const char *name,
Expand Down

0 comments on commit a5937ac

Please sign in to comment.