summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 19:45:42 +0100
committerwm4 <wm4@nowhere>2013-12-21 21:05:02 +0100
commitd8d42b44fc717c695af59c14213d54885088ea37 (patch)
tree9dbfd597e3352249cb5d1fda996d2c0ce1602fe9
parenta2d144fc8f146f96e4fe97b1b2c15828e24f8494 (diff)
downloadmpv-d8d42b44fc717c695af59c14213d54885088ea37.tar.bz2
mpv-d8d42b44fc717c695af59c14213d54885088ea37.tar.xz
m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of course affects all users of this API as well. In stream.c, pass a mp_null_log, because we can't do it properly yet. This will be fixed later.
-rw-r--r--audio/chmap.c16
-rw-r--r--audio/chmap.h4
-rw-r--r--audio/filter/af.c2
-rw-r--r--audio/out/ao.c2
-rw-r--r--common/av_log.c27
-rw-r--r--common/av_log.h3
-rw-r--r--input/input.c12
-rw-r--r--options/m_config.c91
-rw-r--r--options/m_config.h10
-rw-r--r--options/m_option.c339
-rw-r--r--options/m_option.h18
-rw-r--r--options/m_property.c2
-rw-r--r--options/options.c6
-rw-r--r--player/command.c3
-rw-r--r--player/core.h2
-rw-r--r--player/main.c26
-rw-r--r--stream/stream.c2
-rw-r--r--video/filter/vf.c2
-rw-r--r--video/out/vo.c2
-rw-r--r--video/out/vo_opengl.c3
20 files changed, 275 insertions, 297 deletions
diff --git a/audio/chmap.c b/audio/chmap.c
index ce301b6565..a67c4e1c70 100644
--- a/audio/chmap.c
+++ b/audio/chmap.c
@@ -471,19 +471,19 @@ bool mp_chmap_from_str(struct mp_chmap *dst, bstr src)
return true;
}
-void mp_chmap_print_help(int msgt, int msgl)
+void mp_chmap_print_help(struct mp_log *log)
{
- mp_msg(msgt, msgl, "Speakers:\n");
+ mp_info(log, "Speakers:\n");
for (int n = 0; n < MP_SPEAKER_ID_COUNT; n++) {
if (speaker_names[n][0])
- mp_msg(msgt, msgl, " %-16s (%s)\n",
- speaker_names[n][0], speaker_names[n][1]);
+ mp_info(log, " %-16s (%s)\n",
+ speaker_names[n][0], speaker_names[n][1]);
}
- mp_msg(msgt, msgl, "Standard layouts:\n");
+ mp_info(log, "Standard layouts:\n");
for (int n = 0; std_layout_names[n][0]; n++) {
- mp_msg(msgt, msgl, " %-16s (%s)\n",
- std_layout_names[n][0], std_layout_names[n][1]);
+ mp_info(log, " %-16s (%s)\n",
+ std_layout_names[n][0], std_layout_names[n][1]);
}
for (int n = 0; n < MP_NUM_CHANNELS; n++)
- mp_msg(msgt, msgl, " unknown%d\n", n);
+ mp_info(log, " unknown%d\n", n);
}
diff --git a/audio/chmap.h b/audio/chmap.h
index ca1e6c2508..306382db5a 100644
--- a/audio/chmap.h
+++ b/audio/chmap.h
@@ -121,7 +121,9 @@ void mp_chmap_get_reorder(int dst[MP_NUM_CHANNELS], const struct mp_chmap *from,
char *mp_chmap_to_str(const struct mp_chmap *src);
bool mp_chmap_from_str(struct mp_chmap *dst, bstr src);
-void mp_chmap_print_help(int msgt, int msgl);
+
+struct mp_log;
+void mp_chmap_print_help(struct mp_log *log);
// Use these to avoid chaos in case lavc's definition should diverge from MS.
#define mp_chmap_to_waveext mp_chmap_to_lavc
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 3eebd8b385..92ed2ad63e 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -205,7 +205,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
.data = talloc_zero(af, struct mp_audio),
.log = mp_log_new(af, s->log, name),
};
- struct m_config *config = m_config_from_obj_desc(af, &desc);
+ struct m_config *config = m_config_from_obj_desc(af, s->log, &desc);
if (m_config_apply_defaults(config, name, s->opts->af_defs) < 0)
goto error;
if (m_config_set_obj_params(config, args) < 0)
diff --git a/audio/out/ao.c b/audio/out/ao.c
index ab2b15b031..7aea6239d2 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -149,7 +149,7 @@ static struct ao *ao_create(bool probing, struct mpv_global *global,
};
if (ao->driver->encode != !!ao->encode_lavc_ctx)
goto error;
- struct m_config *config = m_config_from_obj_desc(ao, &desc);
+ struct m_config *config = m_config_from_obj_desc(ao, ao->log, &desc);
if (m_config_apply_defaults(config, name, global->opts->ao_defs) < 0)
goto error;
if (m_config_set_obj_params(config, args) < 0)
diff --git a/common/av_log.c b/common/av_log.c
index ba47500572..b007062d1e 100644
--- a/common/av_log.c
+++ b/common/av_log.c
@@ -147,30 +147,31 @@ void init_libav(void)
}
#define V(x) (x)>>16, (x)>>8 & 255, (x) & 255
-static void print_version(int v, char *name, unsigned buildv, unsigned runv)
+static void print_version(struct mp_log *log, int v, char *name,
+ unsigned buildv, unsigned runv)
{
- mp_msg(MSGT_CPLAYER, v, " %-15s %d.%d.%d", name, V(buildv));
+ mp_msg_log(log, v, " %-15s %d.%d.%d", name, V(buildv));
if (buildv != runv)
- mp_msg(MSGT_CPLAYER, v, " (runtime %d.%d.%d)", V(runv));
- mp_msg(MSGT_CPLAYER, v, "\n");
+ mp_msg_log(log, v, " (runtime %d.%d.%d)", V(runv));
+ mp_msg_log(log, v, "\n");
}
#undef V
-void print_libav_versions(int v)
+void print_libav_versions(struct mp_log *log, int v)
{
- mp_msg(MSGT_CPLAYER, v, "%s library versions:\n", LIB_PREFIX);
+ mp_msg_log(log, v, "%s library versions:\n", LIB_PREFIX);
- print_version(v, "libavutil", LIBAVUTIL_VERSION_INT, avutil_version());
- print_version(v, "libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version());
- print_version(v, "libavformat", LIBAVFORMAT_VERSION_INT, avformat_version());
- print_version(v, "libswscale", LIBSWSCALE_VERSION_INT, swscale_version());
+ print_version(log, v, "libavutil", LIBAVUTIL_VERSION_INT, avutil_version());
+ print_version(log, v, "libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version());
+ print_version(log, v, "libavformat", LIBAVFORMAT_VERSION_INT, avformat_version());
+ print_version(log, v, "libswscale", LIBSWSCALE_VERSION_INT, swscale_version());
#if HAVE_LIBAVFILTER
- print_version(v, "libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version());
+ print_version(log, v, "libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version());
#endif
#if HAVE_LIBAVRESAMPLE
- print_version(v, "libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version());
+ print_version(log, v, "libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version());
#endif
#if HAVE_LIBSWRESAMPLE
- print_version(v, "libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version());
+ print_version(log, v, "libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version());
#endif
}
diff --git a/common/av_log.h b/common/av_log.h
index d5c57b0aeb..e941220a11 100644
--- a/common/av_log.h
+++ b/common/av_log.h
@@ -1,2 +1,3 @@
void init_libav(void);
-void print_libav_versions(int v);
+struct mp_log;
+void print_libav_versions(struct mp_log *log, int v);
diff --git a/input/input.c b/input/input.c
index d0eac2529c..8dd8e76bd8 100644
--- a/input/input.c
+++ b/input/input.c
@@ -105,8 +105,8 @@ struct key_name {
#define OARG_INT(def) OPT_INT(ARG(i), 0, OPTDEF_INT(def))
#define OARG_CHOICE(def, c) OPT_CHOICE(ARG(i), 0, c, OPTDEF_INT(def))
-static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
- struct bstr param, void *dst);
+static int parse_cycle_dir(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param, void *dst);
static const struct m_option_type m_option_type_cycle_dir = {
.name = "up|down",
.parse = parse_cycle_dir,
@@ -813,8 +813,8 @@ void mp_input_rm_key_fd(struct input_ctx *ictx, int fd)
input_unlock(ictx);
}
-static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_cycle_dir(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param, void *dst)
{
double val;
if (bstrcmp0(param, "up") == 0) {
@@ -822,7 +822,7 @@ static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
} else if (bstrcmp0(param, "down") == 0) {
val = -1;
} else {
- return m_option_type_double.parse(opt, name, param, dst);
+ return m_option_type_double.parse(log, opt, name, param, dst);
}
*(double *)dst = val;
return 1;
@@ -1041,7 +1041,7 @@ static struct mp_cmd *parse_cmd(struct parse_ctx *ctx, int def_flags)
struct mp_cmd_arg *cmdarg = &cmd->args[cmd->nargs];
cmdarg->type = opt;
cmd->nargs++;
- r = m_option_parse(opt, bstr0(cmd->name), cur_token, &cmdarg->v);
+ r = m_option_parse(ctx->log, opt, bstr0(cmd->name), cur_token, &cmdarg->v);
if (r < 0) {
MP_ERR(ctx, "Command %s: argument %d can't be parsed: %s.\n",
cmd->name, i + 1, m_option_strerror(r));
diff --git a/options/m_config.c b/options/m_config.c
index 2b873e765c..0fc99b0257 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -75,20 +75,18 @@ static int parse_profile(struct m_config *config, const struct m_option *opt,
if (!bstrcmp0(param, "help")) {
struct m_profile *p;
if (!config->profiles) {
- mp_msg(MSGT_CFGPARSER, MSGL_INFO,
- "No profiles have been defined.\n");
+ MP_INFO(config, "No profiles have been defined.\n");
return M_OPT_EXIT - 1;
}
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available profiles:\n");
+ MP_INFO(config, "Available profiles:\n");
for (p = config->profiles; p; p = p->next)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\t%s\t%s\n", p->name,
- p->desc ? p->desc : "");
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
+ MP_INFO(config, "\t%s\t%s\n", p->name, p->desc ? p->desc : "");
+ MP_INFO(config, "\n");
return M_OPT_EXIT - 1;
}
char **list = NULL;
- int r = m_option_type_string_list.parse(opt, name, param, &list);
+ int r = m_option_type_string_list.parse(config->log, opt, name, param, &list);
if (r < 0)
return r;
if (!list || !list[0])
@@ -96,8 +94,7 @@ static int parse_profile(struct m_config *config, const struct m_option *opt,
for (int i = 0; list[i]; i++) {
struct m_profile *p = m_config_get_profile0(config, list[i]);
if (!p) {
- mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Unknown profile '%s'.\n",
- list[i]);
+ MP_WARN(config, "Unknown profile '%s'.\n", list[i]);
r = M_OPT_INVALID;
} else if (set)
m_config_set_profile(config, p, flags);
@@ -113,12 +110,11 @@ static int show_profile(struct m_config *config, bstr param)
if (!param.len)
return M_OPT_MISSING_PARAM;
if (!(p = m_config_get_profile(config, param))) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Unknown profile '%.*s'.\n",
- BSTR_P(param));
+ MP_ERR(config, "Unknown profile '%.*s'.\n", BSTR_P(param));
return M_OPT_EXIT - 1;
}
if (!config->profile_depth)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Profile %s: %s\n", p->name,
+ MP_INFO(config, "Profile %s: %s\n", p->name,
p->desc ? p->desc : "");
config->profile_depth++;
for (i = 0; i < p->num_opts; i++) {
@@ -127,8 +123,7 @@ static int show_profile(struct m_config *config, bstr param)
spc[j] = ' ';
spc[config->profile_depth] = '\0';
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s%s=%s\n", spc,
- p->opts[2 * i], p->opts[2 * i + 1]);
+ MP_INFO(config, "%s%s=%s\n", spc, p->opts[2 * i], p->opts[2 * i + 1]);
if (config->profile_depth < MAX_PROFILE_DEPTH
&& !strcmp(p->opts[2*i], "profile")) {
@@ -149,7 +144,7 @@ static int show_profile(struct m_config *config, bstr param)
}
config->profile_depth--;
if (!config->profile_depth)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
+ MP_INFO(config, "\n");
return M_OPT_EXIT - 1;
}
@@ -187,13 +182,13 @@ static void config_destroy(void *p)
m_option_free(config->opts[n].opt, config->opts[n].data);
}
-struct m_config *m_config_new(void *talloc_ctx, size_t size,
- const void *defaults,
+struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log,
+ size_t size, const void *defaults,
const struct m_option *options)
{
struct m_config *config = talloc(talloc_ctx, struct m_config);
talloc_set_destructor(config, config_destroy);
- *config = (struct m_config) {0};
+ *config = (struct m_config) {.log = log};
// size==0 means a dummy object is created
if (size) {
config->optstruct = talloc_zero_size(config, size);
@@ -205,18 +200,19 @@ struct m_config *m_config_new(void *talloc_ctx, size_t size,
return config;
}
-struct m_config *m_config_from_obj_desc(void *talloc_ctx,
+struct m_config *m_config_from_obj_desc(void *talloc_ctx, struct mp_log *log,
struct m_obj_desc *desc)
{
- return m_config_new(talloc_ctx, desc->priv_size, desc->priv_defaults,
+ return m_config_new(talloc_ctx, log, desc->priv_size, desc->priv_defaults,
desc->options);
}
// Like m_config_from_obj_desc(), but don't allocate option struct.
struct m_config *m_config_from_obj_desc_noalloc(void *talloc_ctx,
+ struct mp_log *log,
struct m_obj_desc *desc)
{
- return m_config_new(talloc_ctx, 0, desc->priv_defaults, desc->options);
+ return m_config_new(talloc_ctx, log, 0, desc->priv_defaults, desc->options);
}
int m_config_set_obj_params(struct m_config *conf, char **args)
@@ -284,7 +280,7 @@ void m_config_backup_opt(struct m_config *config, const char *opt)
if (co) {
ensure_backup(config, co);
} else {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s not found.\n", opt);
+ MP_ERR(config, "Option %s not found.\n", opt);
}
}
@@ -496,15 +492,13 @@ static int m_config_parse_option(struct m_config *config, struct bstr name,
// Check if this option isn't forbidden in the current mode
if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (co->opt->flags & M_OPT_NOCFG)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option can't be used in a config file.\n",
+ MP_ERR(config, "The %.*s option can't be used in a config file.\n",
BSTR_P(name));
return M_OPT_INVALID;
}
if (flags & M_SETOPT_BACKUP) {
if (co->opt->flags & M_OPT_GLOBAL) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option is global and can't be set per-file.\n",
+ MP_ERR(config, "The %.*s option is global and can't be set per-file.\n",
BSTR_P(name));
return M_OPT_INVALID;
}
@@ -529,7 +523,8 @@ static int m_config_parse_option(struct m_config *config, struct bstr name,
return parse_subopts(config, (char *)co->name, prefix, param, flags);
}
- int r = m_option_parse(co->opt, name, param, set ? co->data : NULL);
+ int r = m_option_parse(config->log, co->opt, name, param,
+ set ? co->data : NULL);
if (r >= 0 && set && (flags & M_SETOPT_FROM_CMDLINE)) {
co->is_set_from_cmdline = true;
@@ -551,7 +546,7 @@ static int parse_subopts(struct m_config *config, char *name, char *prefix,
{
char **lst = NULL;
// Split the argument into child options
- int r = m_option_type_subconfig.parse(NULL, bstr0(""), param, &lst);
+ int r = m_option_type_subconfig.parse(config->log, NULL, bstr0(""), param, &lst);
if (r < 0)
return r;
// Parse the child options
@@ -563,9 +558,8 @@ static int parse_subopts(struct m_config *config, char *name, char *prefix,
r = m_config_parse_option(config,bstr0(n), bstr0(lst[2 * i + 1]), flags);
if (r < 0) {
if (r > M_OPT_EXIT) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "Error parsing suboption %s/%s (%s)\n",
- name, lst[2 * i], m_option_strerror(r));
+ MP_ERR(config, "Error parsing suboption %s/%s (%s)\n",
+ name, lst[2 * i], m_option_strerror(r));
r = M_OPT_INVALID;
}
break;
@@ -582,8 +576,8 @@ int m_config_parse_suboptions(struct m_config *config, char *name,
return 0;
int r = parse_subopts(config, name, "", bstr0(subopts), 0);
if (r < 0 && r > M_OPT_EXIT) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing suboption %s (%s)\n",
- name, m_option_strerror(r));
+ MP_ERR(config, "Error parsing suboption %s (%s)\n",
+ name, m_option_strerror(r));
r = M_OPT_INVALID;
}
return r;
@@ -594,8 +588,8 @@ int m_config_set_option_ext(struct m_config *config, struct bstr name,
{
int r = m_config_parse_option(config, name, param, flags);
if (r < 0 && r > M_OPT_EXIT) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Error parsing option %.*s (%s)\n",
- BSTR_P(name), m_option_strerror(r));
+ MP_ERR(config, "Error parsing option %.*s (%s)\n",
+ BSTR_P(name), m_option_strerror(r));
r = M_OPT_INVALID;
}
return r;
@@ -633,7 +627,7 @@ void m_config_print_option_list(const struct m_config *config)
int count = 0;
const char *prefix = config->is_toplevel ? "--" : "";
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Options:\n\n");
+ MP_INFO(config, "Options:\n\n");
for (int i = 0; i < config->num_opts; i++) {
struct m_config_option *co = &config->opts[i];
const struct m_option *opt = co->opt;
@@ -641,16 +635,16 @@ void m_config_print_option_list(const struct m_config *config)
continue;
if (co->is_generated)
continue;
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s%-30.30s", prefix, co->name);
+ MP_INFO(config, " %s%-30.30s", prefix, co->name);
if (opt->type == &m_option_type_choice) {
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " Choices:");
+ MP_INFO(config, " Choices:");
struct m_opt_choice_alternatives *alt = opt->priv;
for (int n = 0; alt[n].name; n++)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", alt[n].name);
+ MP_INFO(config, " %s", alt[n].name);
if (opt->flags & (M_OPT_MIN | M_OPT_MAX))
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " (or an integer)");
+ MP_INFO(config, " (or an integer)");
} else {
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s", co->opt->type->name);
+ MP_INFO(config, " %s", co->opt->type->name);
}
if (opt->flags & (M_OPT_MIN | M_OPT_MAX)) {
snprintf(min, sizeof(min), "any");
@@ -659,23 +653,23 @@ void m_config_print_option_list(const struct m_config *config)
snprintf(min, sizeof(min), "%.14g", opt->min);
if (opt->flags & M_OPT_MAX)
snprintf(max, sizeof(max), "%.14g", opt->max);
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " (%s to %s)", min, max);
+ MP_INFO(config, " (%s to %s)", min, max);
}
char *def = NULL;
if (co->default_data)
def = m_option_print(co->opt, co->default_data);
if (def) {
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " (default: %s)", def);
+ MP_INFO(config, " (default: %s)", def);
talloc_free(def);
}
if (opt->flags & CONF_GLOBAL)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " [global]");
+ MP_INFO(config, " [global]");
if (opt->flags & CONF_NOCFG)
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, " [nocfg]");
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
+ MP_INFO(config, " [nocfg]");
+ MP_INFO(config, "\n");
count++;
}
- mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\nTotal: %d options\n", count);
+ MP_INFO(config, "\nTotal: %d options\n", count);
}
struct m_profile *m_config_get_profile(const struct m_config *config, bstr name)
@@ -731,8 +725,7 @@ void m_config_set_profile(struct m_config *config, struct m_profile *p,
int flags)
{
if (config->profile_depth > MAX_PROFILE_DEPTH) {
- mp_msg(MSGT_CFGPARSER, MSGL_WARN,
- "WARNING: Profile inclusion too deep.\n");
+ MP_WARN(config, "WARNING: Profile inclusion too deep.\n");
return;
}
config->profile_depth++;
diff --git a/options/m_config.h b/options/m_config.h
index 829fa90ba7..2624f45edf 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -34,6 +34,7 @@ struct m_option_type;
struct m_sub_options;
struct m_obj_desc;
struct m_obj_settings;
+struct mp_log;
// Config option
struct m_config_option {
@@ -48,6 +49,8 @@ struct m_config_option {
// Config object
/** \ingroup Config */
typedef struct m_config {
+ struct mp_log *log;
+
// Registered options.
struct m_config_option *opts; // all options, even suboptions
int num_opts;
@@ -77,14 +80,15 @@ typedef struct m_config {
// and a corresponding option switch or sub-option field.
// suboptinit: if not NULL, initialize the suboption string (used for presets)
// Note that the m_config object will keep pointers to defaults and options.
-struct m_config *m_config_new(void *talloc_ctx, size_t size,
- const void *defaults,
+struct m_config *m_config_new(void *talloc_ctx, struct mp_log *log,
+ size_t size, const void *defaults,
const struct m_option *options);
-struct m_config *m_config_from_obj_desc(void *talloc_ctx,
+struct m_config *m_config_from_obj_desc(void *talloc_ctx, struct mp_log *log,
struct m_obj_desc *desc);
struct m_config *m_config_from_obj_desc_noalloc(void *talloc_ctx,
+ struct mp_log *log,
struct m_obj_desc *desc);
int m_config_set_obj_params(struct m_config *conf, char **args);
diff --git a/options/m_option.c b/options/m_option.c
index 32301b5ec3..69d8ba0376 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -117,8 +117,8 @@ static int clamp_flag(const m_option_t *opt, void *val)
return M_OPT_OUT_OF_RANGE;
}
-static int parse_flag(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_flag(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len) {
if (!bstrcmp0(param, "yes")) {
@@ -131,8 +131,7 @@ static int parse_flag(const m_option_t *opt, struct bstr name,
VAL(dst) = opt->min;
return 1;
}
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "Invalid parameter for %.*s flag: %.*s\n",
+ mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_INVALID;
} else {
@@ -173,16 +172,15 @@ const m_option_type_t m_option_type_flag = {
// Single-value, write-only flag
-static int parse_store(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_store(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len == 0 || bstrcmp0(param, "yes") == 0) {
if (dst)
VAL(dst) = opt->max;
return 0;
} else {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "Invalid parameter for %.*s flag: %.*s\n",
+ mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_DISALLOW_PARAM;
}
@@ -202,16 +200,15 @@ const m_option_type_t m_option_type_store = {
#undef VAL
#define VAL(x) (*(float *)(x))
-static int parse_store_float(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_store_float(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len == 0 || bstrcmp0(param, "yes") == 0) {
if (dst)
VAL(dst) = opt->max;
return 0;
} else {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "Invalid parameter for %.*s flag: %.*s\n",
+ mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_DISALLOW_PARAM;
}
@@ -246,8 +243,8 @@ static int clamp_longlong(const m_option_t *opt, void *val)
return r;
}
-static int parse_longlong(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_longlong(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len == 0)
return M_OPT_MISSING_PARAM;
@@ -257,22 +254,19 @@ static int parse_longlong(const m_option_t *opt, struct bstr name,
if (rest.len)
tmp_int = bstrtoll(param, &rest, 0);
if (rest.len) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be an integer: %.*s\n",
+ mp_err(log, "The %.*s option must be an integer: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_INVALID;
}
if ((opt->flags & M_OPT_MIN) && (tmp_int < opt->min)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be >= %d: %.*s\n",
+ mp_err(log, "The %.*s option must be >= %d: %.*s\n",
BSTR_P(name), (int) opt->min, BSTR_P(param));
return M_OPT_OUT_OF_RANGE;
}
if ((opt->flags & M_OPT_MAX) && (tmp_int > opt->max)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be <= %d: %.*s\n",
+ mp_err(log, "The %.*s option must be <= %d: %.*s\n",
BSTR_P(name), (int) opt->max, BSTR_P(param));
return M_OPT_OUT_OF_RANGE;
}
@@ -299,21 +293,21 @@ static int clamp_int64(const m_option_t *opt, void *val)
return r;
}
-static int parse_int(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_int(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
long long tmp;
- int r = parse_longlong(opt, name, param, &tmp);
+ int r = parse_longlong(log, opt, name, param, &tmp);
if (r >= 0 && dst)
*(int *)dst = tmp;
return r;
}
-static int parse_int64(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_int64(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
long long tmp;
- int r = parse_longlong(opt, name, param, &tmp);
+ int r = parse_longlong(log, opt, name, param, &tmp);
if (r >= 0 && dst)
*(int64_t *)dst = tmp;
return r;
@@ -395,8 +389,8 @@ const m_option_type_t m_option_type_int64 = {
.clamp = clamp_int64,
};
-static int parse_intpair(const struct m_option *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_intpair(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len == 0)
return M_OPT_MISSING_PARAM;
@@ -425,7 +419,7 @@ static int parse_intpair(const struct m_option *opt, struct bstr name,
return 1;
bad:
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid integer range "
+ mp_err(log, "Invalid integer range "
"specification for option %.*s: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_INVALID;
@@ -453,8 +447,8 @@ static int clamp_choice(const m_option_t *opt, void *val)
return M_OPT_INVALID;
}
-static int parse_choice(const struct m_option *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_choice(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param, void *dst)
{
struct m_opt_choice_alternatives *alt = opt->priv;
for ( ; alt->name; alt++)
@@ -465,21 +459,20 @@ static int parse_choice(const struct m_option *opt, struct bstr name,
return M_OPT_MISSING_PARAM;
if ((opt->flags & M_OPT_MIN) && (opt->flags & M_OPT_MAX)) {
long long val;
- if (parse_longlong(opt, name, param, &val) == 1) {
+ if (parse_longlong(log, opt, name, param, &val) == 1) {
if (dst)
*(int *)dst = val;
return 1;
}
}
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "Invalid value for option %.*s: %.*s\n",
+ mp_err(log, "Invalid value for option %.*s: %.*s\n",
BSTR_P(name), BSTR_P(param));
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Valid values are:");
+ mp_err(log, "Valid values are:");
for (alt = opt->priv; alt->name; alt++)
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %s", alt->name);
+ mp_err(log, " %s", alt->name);
if ((opt->flags & M_OPT_MIN) && (opt->flags & M_OPT_MAX))
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %g-%g", opt->min, opt->max);
- mp_msg(MSGT_CFGPARSER, MSGL_ERR, "\n");
+ mp_err(log, " %g-%g", opt->min, opt->max);
+ mp_err(log, "\n");
return M_OPT_INVALID;
}
if (dst)
@@ -598,8 +591,8 @@ static int clamp_double(const m_option_t *opt, void *val)
return r;
}
-static int parse_double(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_double(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
if (param.len == 0)
return M_OPT_MISSING_PARAM;
@@ -611,8 +604,7 @@ static int parse_double(const m_option_t *opt, struct bstr name,
tmp_float /= bstrtod(rest, &rest);
if (rest.len) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be a floating point number or a "
+ mp_err(log, "The %.*s option must be a floating point number or a "
"ratio (numerator[:/]denominator): %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_INVALID;
@@ -620,23 +612,20 @@ static int parse_double(const m_option_t *opt, struct bstr name,
if (opt->flags & M_OPT_MIN)
if (tmp_float < opt->min) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be >= %f: %.*s\n",
+ mp_err(log, "The %.*s option must be >= %f: %.*s\n",
BSTR_P(name), opt->min, BSTR_P(param));
return M_OPT_OUT_OF_RANGE;
}
if (opt->flags & M_OPT_MAX)
if (tmp_float > opt->max) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be <= %f: %.*s\n",
+ mp_err(log, "The %.*s option must be <= %f: %.*s\n",
BSTR_P(name), opt->max, BSTR_P(param));
return M_OPT_OUT_OF_RANGE;
}
if (!isfinite(tmp_float)) {
- mp_msg(MSGT_CFGPARSER, MSGL_ERR,
- "The %.*s option must be a finite number: %.*s\n",
+ mp_err(log, "The %.*s option must be a finite number: %.*s\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_OUT_OF_RANGE;
}
@@ -703,11 +692,11 @@ static int clamp_float(const m_option_t *opt, void *val)
return r;
}
-static int parse_float(const m_option_t *opt, struct bstr name,
- struct bstr param, void *dst)
+static int parse_float(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
{
double tmp;
- int r = parse_double(opt, name, param, &tmp);
+ int r = parse_double(log, opt, name, param, &tmp);
if (r == 1 && dst)
VAL(dst) = tmp;
return r;
@@ -799