summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-31 21:40:30 +0200
committerwm4 <wm4@nowhere>2013-07-31 21:46:40 +0200
commit88d79fc00df39dc0180de86c758697f5ab3e56cb (patch)
tree5764f1067cae79dad6a01dccfb241db894b67683 /core/mplayer.c
parentd1de1e090f91a254f066505ee5811feda4d93dde (diff)
downloadmpv-88d79fc00df39dc0180de86c758697f5ab3e56cb.tar.bz2
mpv-88d79fc00df39dc0180de86c758697f5ab3e56cb.tar.xz
mp_msg: introduce new log functions and macros
This has two goals: 1. Getting rid of global variables to make the core library-safe. 2. Getting rid of all the MSGT_* constants and the inconsistent prefixes spread throughout the source code. Both goals are not immediately reached with this commit. It's a huge transition that will take time. There are over >2500 mp_msg calls in the source, which all have to be replaced for this to work. The inconsistent prefixes are in particular annoying. Lots of code manually prefixes messages, e.g. mp_msg(MSGT_VO, MSGL_V, "[vo] ..."). Sometimes the prefixes don't even follow this convention (for example vo_direct3d.c uses "<vo_direct3d>" as prefix). This commit allows automatically adding prefixes on request, so consistency will hopefully improve. For now, this commit adds unused stuff, and behavior should not change. In mplayer.c, move the GetCpuCaps() call, because that used mp_msg() before mp_msg_init() was run.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 0238e10be3..626c95111f 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -63,6 +63,7 @@
#include <errno.h>
+#include "core/mpv_global.h"
#include "core/mp_msg.h"
#include "av_log.h"
@@ -585,6 +586,8 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx,
// must be last since e.g. mp_msg uses option values
// that will be freed by this.
+
+ mp_msg_uninit(mpctx->global);
talloc_free(mpctx);
#ifdef CONFIG_COCOA
@@ -4562,8 +4565,6 @@ static void osdep_preinit(int *p_argc, char ***p_argv)
if (enable_talloc && strcmp(enable_talloc, "1") == 0)
talloc_enable_leak_report();
- GetCpuCaps(&gCpuCaps);
-
#ifdef __MINGW32__
mp_get_converted_argv(p_argc, p_argv);
#endif
@@ -4603,10 +4604,6 @@ static int mpv_main(int argc, char *argv[])
.playlist = talloc_struct(mpctx, struct playlist, {0}),
};
- mp_msg_init();
- init_libav();
- screenshot_init(mpctx);
-
// Create the config context and register the options
mpctx->mconfig = m_config_new(mpctx, sizeof(struct MPOpts),
&mp_default_opts, mp_opts, NULL);
@@ -4616,6 +4613,18 @@ static int mpv_main(int argc, char *argv[])
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, "!mpv");
+
+ init_libav();
+ GetCpuCaps(&gCpuCaps);
+ screenshot_init(mpctx);
+
// Preparse the command line
m_config_preparse_command_line(mpctx->mconfig, argc, argv);