msg: change --msglevel, reduce legacy glue

Basically, reimplement --msglevel. Instead of making the new msg code
use the legacy code, make the legacy code use the reimplemented
functionality.

The handling of the deprecated --identify switch changes. It temporarily
stops working; this will be fixed in later commits.

The actual sub-options syntax (like --msglevel-vo=...) goes away, but I
bet nobody knew about this or used this anyway.
This commit is contained in:
wm4 2013-12-18 19:04:30 +01:00
parent 5162c2709e
commit 6a8fc3f5e3
9 changed files with 190 additions and 140 deletions

View File

@ -179,6 +179,7 @@ Command Line Switches
``-panscanrange`` ``--video-zoom``, ``--video-pan-x/y``
``-pp ...`` ``'--vf=pp=[...]'``
``-pphelp`` ``--vf=pp:help``
``-identify`` ``--msglevel=identify=trace``
=========================== ========================================
.. note::

View File

@ -1345,7 +1345,9 @@ OPTIONS
Control verbosity directly for each module. The ``all`` module changes the
verbosity of all the modules not explicitly specified on the command line.
See ``--msglevel=help`` for a list of all modules.
Run mpv with ``--msglevel=all=trace`` to see all messages mpv outputs. You
can use the module names printed in the output (prefixed to each line in
``[...]``) to limit the output to interesting modules.
.. note::
@ -1356,17 +1358,19 @@ OPTIONS
Available levels:
:-1: complete silence
:0: fatal messages only
:1: error messages
:2: warning messages
:3: short hints
:4: informational messages
:5: status messages (default)
:6: verbose messages
:7: debug level 2
:8: debug level 3
:9: debug level 4
:no: complete silence
:fatal: fatal messages only
:error: error messages
:warn: warning messages
:info: informational messages
:status: status messages (default)
:v: verbose messages
:debug: debug messages
:trace: very noisy debug messages
One special case is the ``identify`` module name. This is silenced by
default, and can be set to ``trace`` level to enable the remains of the
code once enabled with the ``-identify`` option.
``--msgmodule``
Prepend module name in front of each console message.

View File

@ -22,10 +22,15 @@
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <pthread.h>
#include "talloc.h"
#include "bstr/bstr.h"
#include "compat/atomics.h"
#include "common/common.h"
#include "common/global.h"
#include "options/options.h"
#include "osdep/terminal.h"
#include "osdep/io.h"
@ -40,24 +45,32 @@ struct mp_log_root {
* control the terminal, which is global anyway). But for now, there is
* not much. */
struct mpv_global *global;
char *msglevels; // protected by mp_msg_lock
/* This is incremented every time the msglevels must be reloaded.
* (This is perhaps better than maintaining a globally accessible and
* synchronized mp_log tree.) */
int64_t reload_counter;
};
struct mp_log {
struct mp_log_root *root;
const char *prefix;
const char *verbose_prefix;
int legacy_mod;
int level;
int64_t reload_counter;
};
// Protects some (not all) state in mp_log_root
static pthread_mutex_t mp_msg_lock = PTHREAD_MUTEX_INITIALIZER;
// should not exist
static bool initialized;
static struct mp_log *legacy_logs[MSGT_MAX];
bool mp_msg_stdout_in_use;
int mp_msg_levels[MSGT_MAX]; // verbose level of this module. initialized to -2
int mp_msg_level_all = MSGL_STATUS;
int verbose;
bool mp_msg_mute;
int mp_smode;
int mp_msg_color = 1;
int mp_msg_module;
int mp_msg_cancolor;
@ -67,31 +80,57 @@ static int header = 1;
// indicates if last line printed was a status line
static int statusline;
static void mp_msg_do_init(void){
int i;
static const struct mp_log null_log = {0};
struct mp_log *const mp_null_log = (struct mp_log *)&null_log;
static void mp_msg_do_init(void)
{
char *env = getenv("MPV_VERBOSE");
if (env)
verbose = atoi(env);
for(i=0;i<MSGT_MAX;i++) mp_msg_levels[i] = -2;
mp_msg_cancolor = isatty(fileno(stdout));
mp_msg_levels[MSGT_IDENTIFY] = -1; // no -identify output by default
}
int mp_msg_test(int mod, int lev)
static bool match_mod(const char *name, bstr mod)
{
if (mp_msg_mute)
if (bstr_equals0(mod, "all"))
return true;
// Path prefix matches
bstr b = bstr0(name);
return bstr_eatstart(&b, mod) && (bstr_eatstart0(&b, "/") || !b.len);
}
static void update_loglevel(struct mp_log *log)
{
pthread_mutex_lock(&mp_msg_lock);
log->level = MSGL_STATUS + verbose; // default log level
// Stupid exception for the remains of -identify
if (match_mod(log->verbose_prefix, bstr0("identify")))
log->level = -1;
bstr s = bstr0(log->root->msglevels);
bstr mod;
int level;
while (mp_msg_split_msglevel(&s, &mod, &level) > 0) {
if (match_mod(log->verbose_prefix, mod))
log->level = level;
}
log->reload_counter = log->root->reload_counter;
pthread_mutex_unlock(&mp_msg_lock);
}
bool mp_msg_test_log(struct mp_log *log, int lev)
{
if (mp_msg_mute || !log->root)
return false;
if (lev == MSGL_STATUS) {
// skip status line output if stderr is a tty but in background
if (terminal_in_background())
return false;
}
return lev <= (mp_msg_levels[mod] == -2 ? mp_msg_level_all + verbose : mp_msg_levels[mod]);
}
bool mp_msg_test_log(struct mp_log *log, int lev)
{
return mp_msg_test(log->legacy_mod, lev);
mp_memory_barrier();
if (log->reload_counter != log->root->reload_counter)
update_loglevel(log);
return lev <= log->level || (mp_smode && lev == MSGL_SMODE);
}
static int mp_msg_docolor(void)
@ -101,13 +140,12 @@ static int mp_msg_docolor(void)
static void set_msg_color(FILE* stream, int lev)
{
static const int v_colors[10] = {9, 1, 3, 3, -1, -1, 2, 8, 8, 8};
static const int v_colors[] = {9, 1, 3, 3, -1, -1, 2, 8, 8, 8, 9};
if (mp_msg_docolor())
terminal_set_foreground_color(stream, v_colors[lev]);
}
static void mp_msg_log_va(struct mp_log *log, int lev, const char *format,
va_list va)
void mp_msg_log_va(struct mp_log *log, int lev, const char *format, va_list va)
{
char tmp[MSGSIZE_MAX];
FILE *stream =
@ -161,6 +199,13 @@ void mp_msg(int mod, int lev, const char *format, ...)
va_end(va);
}
int mp_msg_test(int mod, int lev)
{
assert(initialized);
assert(mod >= 0 && mod < MSGT_MAX);
return mp_msg_test_log(legacy_logs[mod], lev);
}
// legacy names
static const char *module_text[MSGT_MAX] = {
"global",
@ -224,6 +269,8 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
assert(parent);
assert(name);
struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
if (!parent->root)
return log; // same as null_log
log->root = parent->root;
if (name[0] == '!') {
name = &name[1];
@ -242,13 +289,6 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
log->prefix = NULL;
if (!log->verbose_prefix[0])
log->verbose_prefix = "global";
log->legacy_mod = parent->legacy_mod;
for (int n = 0; n < MSGT_MAX; n++) {
if (module_text[n] && strcmp(name, module_text[n]) == 0) {
log->legacy_mod = n;
break;
}
}
return log;
}
@ -259,6 +299,7 @@ void mp_msg_init(struct mpv_global *global)
struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
root->global = global;
root->reload_counter = 1;
struct mp_log dummy = { .root = root };
struct mp_log *log = mp_log_new(root, &dummy, "");
@ -278,6 +319,17 @@ struct mpv_global *mp_log_get_global(struct mp_log *log)
return log->root->global;
}
void mp_msg_update_msglevels(struct mpv_global *global)
{
struct mp_log_root *root = global->log->root;
pthread_mutex_lock(&mp_msg_lock);
talloc_free(root->msglevels);
root->msglevels = talloc_strdup(root, global->opts->msglevels);
mp_atomic_add_and_fetch(&root->reload_counter, 1);
mp_memory_barrier();
pthread_mutex_unlock(&mp_msg_lock);
}
void mp_msg_uninit(struct mpv_global *global)
{
talloc_free(global->log->root);
@ -292,3 +344,38 @@ void mp_msg_log(struct mp_log *log, int lev, const char *format, ...)
mp_msg_log_va(log, lev, format, va);
va_end(va);
}
static const char *level_names[] = {
[MSGL_FATAL] = "fatal",
[MSGL_ERR] = "error",
[MSGL_WARN] = "warn",
[MSGL_INFO] = "info",
[MSGL_STATUS] = "status",
[MSGL_V] = "v",
[MSGL_DBG2] = "debug",
[MSGL_DBG5] = "trace",
};
int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level)
{
if (s->len == 0)
return 0;
bstr elem, rest;
bstr_split_tok(*s, ":", &elem, &rest);
bstr mod, level;
if (!bstr_split_tok(elem, "=", &mod, &level) || mod.len == 0)
return -1;
int ilevel = -1;
for (int n = 0; n < MP_ARRAY_SIZE(level_names); n++) {
if (level_names[n] && bstr_equals0(level, level_names[n])) {
ilevel = n;
break;
}
}
if (ilevel < 0 && !bstr_equals0(level, "no"))
return -1;
*s = rest;
*out_mod = mod;
*out_level = ilevel;
return 1;
}

View File

@ -31,6 +31,10 @@ struct mp_log;
extern int verbose;
extern bool mp_msg_mute;
extern bool mp_msg_stdout_in_use;
extern int mp_smode; // slave mode compatibility glue
// A mp_log instance that never outputs anything.
extern struct mp_log *const mp_null_log;
// Verbosity levels.
#define MSGL_FATAL 0 // will exit/abort (note: msg.c doesn't exit or abort)
@ -44,18 +48,19 @@ extern bool mp_msg_stdout_in_use;
#define MSGL_DBG3 8 // ...
#define MSGL_DBG4 9 // ....
#define MSGL_DBG5 10 // .....
#define MSGL_SMODE 11 // old slave mode (-identify)
struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
const char *name);
void mp_msg_log(struct mp_log *log, int lev, const char *format, ...)
PRINTF_ATTRIBUTE(3, 4);
void mp_msg_log_va(struct mp_log *log, int lev, const char *format, va_list va);
// Convenience macros, typically called with a pointer to a context struct
// as first argument, which has a "struct mp_log log;" member.
#define MP_MSG(obj, lev, ...) mp_msg_log((obj)->log, lev, __VA_ARGS__)
#define MP_MSGT(obj, lev, ...) mp_msgt_log((obj)->log, lev, __VA_ARGS__)
#define MP_FATAL(obj, ...) MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
#define MP_ERR(obj, ...) MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
@ -64,6 +69,7 @@ void mp_msg_log(struct mp_log *log, int lev, const char *format, ...)
#define MP_VERBOSE(obj, ...) MP_MSG(obj, MSGL_V, __VA_ARGS__)
#define MP_DBG(obj, ...) MP_MSG(obj, MSGL_DBG2, __VA_ARGS__)
#define MP_TRACE(obj, ...) MP_MSG(obj, MSGL_DBG5, __VA_ARGS__)
#define MP_SMODE(obj, ...) MP_MSG(obj, MSGL_SMODE, __VA_ARGS__)
#define mp_fatal(log, ...) mp_msg_log(log, MSGL_FATAL, __VA_ARGS__)
#define mp_err(log, ...) mp_msg_log(log, MSGL_ERR, __VA_ARGS__)
@ -76,9 +82,13 @@ void mp_msg_log(struct mp_log *log, int lev, const char *format, ...)
struct mpv_global;
void mp_msg_init(struct mpv_global *global);
void mp_msg_uninit(struct mpv_global *global);
void mp_msg_update_msglevels(struct mpv_global *global);
struct mpv_global *mp_log_get_global(struct mp_log *log);
struct bstr;
int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level);
// --- Legacy
// Note: using mp_msg_log or the MP_ERR/... macros is preferred.

View File

@ -1332,6 +1332,47 @@ const m_option_type_t m_option_type_subconfig_struct = {
.parse = parse_subconf,
};
#undef VAL
#define VAL(x) (*(char **)(x))
static int parse_msglevels(const m_option_t *opt, struct bstr name,
struct bstr param, void *dst)
{
if (param.start == NULL)
return M_OPT_MISSING_PARAM;
bstr s = param;
while (1) {
int res = mp_msg_split_msglevel(&s, &(bstr){0}, &(int){0});
if (res == 0)
break;
if (res < 0) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Invalid syntax: %.*s\n", BSTR_P(s));
return M_OPT_INVALID;
}
}
if (dst) {
talloc_free(VAL(dst));
VAL(dst) = bstrdup0(NULL, param);
}
return 1;
}
const m_option_type_t m_option_type_msglevels = {
.name = "Output verbosity levels",
.size = sizeof(char *),
.flags = M_OPT_TYPE_DYNAMIC,
.parse = parse_msglevels,
.print = print_str,
.copy = copy_str,
.free = free_str,
};
#undef VAL
static int parse_color(const m_option_t *opt, struct bstr name,
struct bstr param, void *dst)
{

View File

@ -48,7 +48,7 @@ extern const m_option_type_t m_option_type_string_list;
extern const m_option_type_t m_option_type_time;
extern const m_option_type_t m_option_type_rel_time;
extern const m_option_type_t m_option_type_choice;
extern const m_option_type_t m_option_type_msglevels;
extern const m_option_type_t m_option_type_print;
extern const m_option_type_t m_option_type_print_func;
extern const m_option_type_t m_option_type_print_func_param;

View File

@ -190,105 +190,6 @@ static const m_option_t mfopts_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};
extern int mp_msg_levels[MSGT_MAX];
extern int mp_msg_level_all;
static const m_option_t msgl_config[]={
{ "all", &mp_msg_level_all, CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL},
{ "global", &mp_msg_levels[MSGT_GLOBAL], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "cplayer", &mp_msg_levels[MSGT_CPLAYER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "vo", &mp_msg_levels[MSGT_VO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "ao", &mp_msg_levels[MSGT_AO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "demuxer", &mp_msg_levels[MSGT_DEMUXER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "ds", &mp_msg_levels[MSGT_DS], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "demux", &mp_msg_levels[MSGT_DEMUX], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "header", &mp_msg_levels[MSGT_HEADER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "avsync", &mp_msg_levels[MSGT_AVSYNC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "autoq", &mp_msg_levels[MSGT_AUTOQ], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "cfgparser", &mp_msg_levels[MSGT_CFGPARSER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "decaudio", &mp_msg_levels[MSGT_DECAUDIO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "decvideo", &mp_msg_levels[MSGT_DECVIDEO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "seek", &mp_msg_levels[MSGT_SEEK], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "win32", &mp_msg_levels[MSGT_WIN32], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "open", &mp_msg_levels[MSGT_OPEN], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "dvd", &mp_msg_levels[MSGT_DVD], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "parsees", &mp_msg_levels[MSGT_PARSEES], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "lirc", &mp_msg_levels[MSGT_LIRC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "stream", &mp_msg_levels[MSGT_STREAM], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "cache", &mp_msg_levels[MSGT_CACHE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "encode", &mp_msg_levels[MSGT_ENCODE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "xacodec", &mp_msg_levels[MSGT_XACODEC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "tv", &mp_msg_levels[MSGT_TV], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "radio", &mp_msg_levels[MSGT_RADIO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "osdep", &mp_msg_levels[MSGT_OSDEP], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "spudec", &mp_msg_levels[MSGT_SPUDEC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "playtree", &mp_msg_levels[MSGT_PLAYTREE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "input", &mp_msg_levels[MSGT_INPUT], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "vfilter", &mp_msg_levels[MSGT_VFILTER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "osd", &mp_msg_levels[MSGT_OSD], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "network", &mp_msg_levels[MSGT_NETWORK], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "cpudetect", &mp_msg_levels[MSGT_CPUDETECT], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "codeccfg", &mp_msg_levels[MSGT_CODECCFG], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "sws", &mp_msg_levels[MSGT_SWS], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "vobsub", &mp_msg_levels[MSGT_VOBSUB], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "subreader", &mp_msg_levels[MSGT_SUBREADER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "afilter", &mp_msg_levels[MSGT_AFILTER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "netst", &mp_msg_levels[MSGT_NETST], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "muxer", &mp_msg_levels[MSGT_MUXER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "ass", &mp_msg_levels[MSGT_ASS], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "statusline", &mp_msg_levels[MSGT_STATUSLINE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{ "fixme", &mp_msg_levels[MSGT_FIXME], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
{"help", "Available msg modules:\n"
" global - common player errors/information\n"
" cplayer - console player (mplayer.c)\n"
" vo - libvo\n"
" ao - libao\n"
" demuxer - demuxer.c (general stuff)\n"
" ds - demux stream (add/read packet etc)\n"
" demux - fileformat-specific stuff (demux_*.c)\n"
" header - fileformat-specific header (*header.c)\n"
" avsync - mplayer.c timer stuff\n"
" autoq - mplayer.c auto-quality stuff\n"
" cfgparser - cfgparser.c\n"
" decaudio - av decoder\n"
" decvideo\n"
" seek - seeking code\n"
" win32 - win32 dll stuff\n"
" open - open.c (stream opening)\n"
" dvd - open.c (DVD init/read/seek)\n"
" parsees - parse_es.c (mpeg stream parser)\n"
" lirc - lirc_mp.c and input lirc driver\n"
" stream - stream.c\n"
" cache - cache2.c\n"
" encode - encode_lavc.c and associated vo/ao drivers\n"
" xacodec - XAnim codecs\n"
" tv - TV input subsystem\n"
" osdep - OS-dependent parts\n"
" spudec - spudec.c\n"
" playtree - Playtree handling (playtree.c, playtreeparser.c)\n"
" input\n"
" vfilter\n"
" osd\n"
" network\n"
" cpudetect\n"
" codeccfg\n"
" sws\n"
" vobsub\n"
" subreader\n"
" afilter - Audio filter messages\n"
" netst - Netstream\n"
" muxer - muxer layer\n"
" identify - identify output\n"
" ass - libass messages\n"
" statusline - playback/encoding status line\n"
" fixme - messages not yet fixed to map to module\n"
"\n", CONF_TYPE_PRINT, CONF_GLOBAL | CONF_NOCFG, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#if HAVE_TV
static const m_option_t tvscan_conf[]={
{"autostart", &stream_tv_defaults.scan, CONF_TYPE_FLAG, 0, 0, 1, NULL},
@ -336,7 +237,8 @@ const m_option_t mp_opts[] = {
// ------------------------- common options --------------------
OPT_FLAG("quiet", quiet, CONF_GLOBAL),
{"really-quiet", &verbose, CONF_TYPE_STORE, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},
{"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
OPT_GENERAL(char*, "msglevel", msglevels, CONF_GLOBAL|CONF_PRE_PARSE,
.type = &m_option_type_msglevels),
{"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL | CONF_PRE_PARSE, 0, 1, NULL},
{"msgmodule", &mp_msg_module, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
#if HAVE_PRIORITY
@ -730,7 +632,7 @@ const m_option_t mp_opts[] = {
{"", (void *) mp_input_opts, CONF_TYPE_SUBCONFIG},
OPT_FLAG("list-properties", list_properties, CONF_GLOBAL),
{"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL},
{"identify", &mp_smode, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"help", (void *) mp_help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
{"h", (void *) mp_help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
{"version", (void *)print_version_opt, CONF_TYPE_PRINT_FUNC, CONF_NOCFG|CONF_GLOBAL|M_OPT_PRE_PARSE},

View File

@ -44,6 +44,8 @@ typedef struct mp_vo_opts {
} mp_vo_opts;
typedef struct MPOpts {
char *msglevels;
char **reset_options;
char **lua_files;
int lua_load_osc;

View File

@ -338,6 +338,7 @@ static int mpv_main(int argc, char *argv[])
// Preparse the command line
m_config_preparse_command_line(mpctx->mconfig, argc, argv);
mp_msg_update_msglevels(mpctx->global);
mp_print_version(false);
@ -354,6 +355,8 @@ static int mpv_main(int argc, char *argv[])
}
}
mp_msg_update_msglevels(mpctx->global);
if (handle_help_options(mpctx))
exit_player(mpctx, EXIT_NONE);