From d8d42b44fc717c695af59c14213d54885088ea37 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 19:45:42 +0100 Subject: 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. --- player/command.c | 3 ++- player/core.h | 2 +- player/main.c | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 9951eb1293..03b444c062 100644 --- a/player/command.c +++ b/player/command.c @@ -2294,7 +2294,8 @@ static int edit_filters(struct MPContext *mpctx, enum stream_type mediatype, struct m_obj_settings *new_chain = NULL; m_option_copy(co->opt, &new_chain, co->data); - int r = m_option_parse(co->opt, bstr0(optname), bstr0(arg), &new_chain); + int r = m_option_parse(mpctx->log, co->opt, bstr0(optname), bstr0(arg), + &new_chain); if (r >= 0) r = set_filters(mpctx, mediatype, new_chain); diff --git a/player/core.h b/player/core.h index 9fe52b690b..4aafc53d5b 100644 --- a/player/core.h +++ b/player/core.h @@ -387,7 +387,7 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e); void mp_play_files(struct MPContext *mpctx); // main.c -void mp_print_version(int always); +void mp_print_version(struct mp_log *log, int always); // misc.c double get_start_time(struct MPContext *mpctx); diff --git a/player/main.c b/player/main.c index 056f7c16e5..db2794c1ad 100644 --- a/player/main.c +++ b/player/main.c @@ -94,13 +94,13 @@ const char mp_help_text[] = " --list-options list all mpv options\n" "\n"; -void mp_print_version(int always) +void mp_print_version(struct mp_log *log, int always) { int v = always ? MSGL_INFO : MSGL_V; - mp_msg(MSGT_CPLAYER, v, + mp_msg_log(log, v, "%s (C) 2000-2013 mpv/MPlayer/mplayer2 projects\n built on %s\n", mplayer_version, mplayer_builddate); - print_libav_versions(v); - mp_msg(MSGT_CPLAYER, v, "\n"); + print_libav_versions(log, v); + mp_msg_log(log, v, "\n"); } static MP_NORETURN void exit_player(struct MPContext *mpctx, @@ -292,8 +292,14 @@ static int mpv_main(int argc, char *argv[]) .playlist = talloc_struct(mpctx, struct playlist, {0}), }; + mpctx->global = talloc_zero(mpctx, struct mpv_global); + + // Nothing must call mp_msg*() and related before this + mp_msg_init(mpctx->global); + mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer"); + // Create the config context and register the options - mpctx->mconfig = m_config_new(mpctx, sizeof(struct MPOpts), + mpctx->mconfig = m_config_new(mpctx, mpctx->log, sizeof(struct MPOpts), &mp_default_opts, mp_opts); mpctx->opts = mpctx->mconfig->optstruct; mpctx->mconfig->includefunc = cfg_include; @@ -302,14 +308,8 @@ static int mpv_main(int argc, char *argv[]) mpctx->mconfig->is_toplevel = true; struct MPOpts *opts = mpctx->opts; - - - mpctx->global = talloc_zero(mpctx, struct mpv_global); mpctx->global->opts = opts; - // Nothing must call mp_msg() before this - mp_msg_init(mpctx->global); - mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer"); init_libav(); GetCpuCaps(&gCpuCaps); @@ -321,7 +321,7 @@ static int mpv_main(int argc, char *argv[]) m_config_preparse_command_line(mpctx->mconfig, argc, argv); mp_msg_update_msglevels(mpctx->global); - mp_print_version(false); + mp_print_version(mpctx->log, false); if (!mp_parse_cfgfiles(mpctx)) exit_player(mpctx, EXIT_ERROR); @@ -348,7 +348,7 @@ static int mpv_main(int argc, char *argv[]) MP_VERBOSE(mpctx, "\n"); if (!mpctx->playlist->first && !opts->player_idle_mode) { - mp_print_version(true); + mp_print_version(mpctx->log, true); MP_INFO(mpctx, "%s", mp_help_text); exit_player(mpctx, EXIT_NONE); } -- cgit v1.2.3