diff options
Diffstat (limited to 'options')
-rw-r--r-- | options/m_config.c | 47 | ||||
-rw-r--r-- | options/m_config.h | 1 | ||||
-rw-r--r-- | options/m_option.h | 3 | ||||
-rw-r--r-- | options/m_property.c | 10 | ||||
-rw-r--r-- | options/options.c | 14 |
5 files changed, 37 insertions, 38 deletions
diff --git a/options/m_config.c b/options/m_config.c index 030c144dfc..0f112dcefb 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -35,6 +35,7 @@ #include "m_config.h" #include "options/m_option.h" #include "common/msg.h" +#include "common/msg_control.h" static const union m_option_value default_value; @@ -114,7 +115,6 @@ static int parse_profile(struct m_config *config, const struct m_option *opt, static int show_profile(struct m_config *config, bstr param) { struct m_profile *p; - int i, j; if (!param.len) return M_OPT_MISSING_PARAM; if (!(p = m_config_get_profile(config, param))) { @@ -125,25 +125,18 @@ static int show_profile(struct m_config *config, bstr param) MP_INFO(config, "Profile %s: %s\n", p->name, p->desc ? p->desc : ""); config->profile_depth++; - for (i = 0; i < p->num_opts; i++) { - char spc[config->profile_depth + 1]; - for (j = 0; j < config->profile_depth; j++) - spc[j] = ' '; - spc[config->profile_depth] = '\0'; - - MP_INFO(config, "%s%s=%s\n", spc, p->opts[2 * i], p->opts[2 * i + 1]); + for (int i = 0; i < p->num_opts; i++) { + MP_INFO(config, "%*s%s=%s\n", config->profile_depth, "", + p->opts[2 * i], p->opts[2 * i + 1]); if (config->profile_depth < MAX_PROFILE_DEPTH && !strcmp(p->opts[2*i], "profile")) { char *e, *list = p->opts[2 * i + 1]; while ((e = strchr(list, ','))) { int l = e - list; - char tmp[l+1]; if (!l) continue; - memcpy(tmp, list, l); - tmp[l] = '\0'; - show_profile(config, bstr0(tmp)); + show_profile(config, (bstr){list, e - list}); list = e + 1; } if (list[0] != '\0') @@ -557,18 +550,23 @@ static int handle_set_opt_flags(struct m_config *config, return set ? 2 : 1; } -static void handle_set_from_cmdline(struct m_config *config, - struct m_config_option *co) +static void handle_on_set(struct m_config *config, struct m_config_option *co, + int flags) { - co->is_set_from_cmdline = true; - // Mark aliases too - if (co->data) { - for (int n = 0; n < config->num_opts; n++) { - struct m_config_option *co2 = &config->opts[n]; - if (co2->data == co->data) - co2->is_set_from_cmdline = true; + if (flags & M_SETOPT_FROM_CMDLINE) { + co->is_set_from_cmdline = true; + // Mark aliases too + if (co->data) { + for (int n = 0; n < config->num_opts; n++) { + struct m_config_option *co2 = &config->opts[n]; + if (co2->data == co->data) + co2->is_set_from_cmdline = true; + } } } + + if (config->global && (co->opt->flags & M_OPT_TERM)) + mp_msg_update_msglevels(config->global); } // The type data points to is as in: m_config_get_co(config, name)->opt @@ -588,8 +586,7 @@ int m_config_set_option_raw(struct m_config *config, struct m_config_option *co, return r; m_option_copy(co->opt, co->data, data); - if (flags & M_SETOPT_FROM_CMDLINE) - handle_set_from_cmdline(config, co); + handle_on_set(config, co, flags); return 0; } @@ -637,8 +634,8 @@ static int m_config_parse_option(struct m_config *config, struct bstr name, r = m_option_parse(config->log, co->opt, name, param, set ? co->data : NULL); - if (r >= 0 && set && (flags & M_SETOPT_FROM_CMDLINE)) - handle_set_from_cmdline(config, co); + if (r >= 0 && set) + handle_on_set(config, co, flags); return r; } diff --git a/options/m_config.h b/options/m_config.h index 89f620b6d3..ed34389921 100644 --- a/options/m_config.h +++ b/options/m_config.h @@ -51,6 +51,7 @@ struct m_config_option { /** \ingroup Config */ typedef struct m_config { struct mp_log *log; + struct mpv_global *global; // can be NULL // Registered options. struct m_config_option *opts; // all options, even suboptions diff --git a/options/m_option.h b/options/m_option.h index 17756885d9..320a9e5b99 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -363,6 +363,9 @@ struct m_option { // The option expects a file name (or a list of file names) #define M_OPT_FILE (1 << 11) +// Logging-related option - used to update log/terminal settings eagerly +#define M_OPT_TERM (1 << 12) + // These are kept for compatibility with older code. #define CONF_MIN M_OPT_MIN #define CONF_MAX M_OPT_MAX diff --git a/options/m_property.c b/options/m_property.c index 9af3c91081..9318d5b7d2 100644 --- a/options/m_property.c +++ b/options/m_property.c @@ -49,14 +49,12 @@ static struct m_property *m_property_list_find(const struct m_property *list, static int do_action(const struct m_property *prop_list, const char *name, int action, void *arg, void *ctx) { - const char *sep; struct m_property *prop; struct m_property_action_arg ka; - if ((sep = strchr(name, '/')) && sep[1]) { - int len = sep - name; - char base[len + 1]; - memcpy(base, name, len); - base[len] = 0; + const char *sep = strchr(name, '/'); + if (sep && sep[1]) { + char base[128]; + snprintf(base, sizeof(base), "%.*s", (int)(sep - name), name); prop = m_property_list_find(prop_list, base); ka = (struct m_property_action_arg) { .key = sep + 1, diff --git a/options/options.c b/options/options.c index 45c1b0e277..5cb5e2b522 100644 --- a/options/options.c +++ b/options/options.c @@ -113,14 +113,14 @@ const m_option_t mp_opts[] = { // ------------------------- common options -------------------- OPT_FLAG("quiet", quiet, CONF_GLOBAL), OPT_FLAG_STORE("really-quiet", verbose, CONF_GLOBAL | CONF_PRE_PARSE, -10), - OPT_FLAG("terminal", use_terminal, CONF_GLOBAL | CONF_PRE_PARSE), - OPT_GENERAL(char**, "msg-level", msg_levels, CONF_GLOBAL|CONF_PRE_PARSE, - .type = &m_option_type_msglevels), + OPT_FLAG("terminal", use_terminal, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_TERM), + OPT_GENERAL(char**, "msg-level", msg_levels, CONF_GLOBAL|CONF_PRE_PARSE | + M_OPT_TERM, .type = &m_option_type_msglevels), OPT_STRING("dump-stats", dump_stats, CONF_GLOBAL | CONF_PRE_PARSE), - OPT_FLAG("msg-color", msg_color, CONF_GLOBAL | CONF_PRE_PARSE), + OPT_FLAG("msg-color", msg_color, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_TERM), OPT_STRING("log-file", log_file, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_FILE), - OPT_FLAG("msg-module", msg_module, CONF_GLOBAL), - OPT_FLAG("msg-time", msg_time, CONF_GLOBAL), + OPT_FLAG("msg-module", msg_module, CONF_GLOBAL | M_OPT_TERM), + OPT_FLAG("msg-time", msg_time, CONF_GLOBAL | M_OPT_TERM), #ifdef _WIN32 OPT_CHOICE("priority", w32_priority, 0, ({"no", 0}, @@ -800,7 +800,7 @@ const struct MPOpts mp_default_opts = { .sub_cp = "auto", .screenshot_template = "mpv-shot%n", - .hwdec_codecs = "h264,vc1,wmv3,hevc", + .hwdec_codecs = "h264,vc1,wmv3,hevc,mpeg2video", .index_mode = 1, |