summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-27 21:26:00 +0200
committerwm4 <wm4@nowhere>2013-07-28 18:44:21 +0200
commitc070fa865fcf75cace05bf492a68f6a2c6137fb3 (patch)
tree87cdc963094ed5604121d5f2f6e354cf52503c1e /core/mplayer.c
parentda2b4aa5870f407ad322b6116ed8d66a66dbeadf (diff)
downloadmpv-c070fa865fcf75cace05bf492a68f6a2c6137fb3.tar.bz2
mpv-c070fa865fcf75cace05bf492a68f6a2c6137fb3.tar.xz
m_config: refactor some things
Change how m_config is initialized. Make it more uniform; now all m_config structs are intialized in exactly the same way. Make sure there's only a single m_option[] array defining the options, and keep around the pointer to the optstruct default value, and the optstruct size as well. This will allow reconstructing the option default values in the following commit. In particular, stop pretending that the handling of some special options (like --profile, --v, and some others) is in any way elegant, and make them explicit hacks. This is really more readable and easier to understand than what was before, and simplifies the code.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index e7fc84e645..44cc3f5540 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -563,7 +563,7 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx,
timeEndPeriod(1);
#endif
- mp_input_uninit(mpctx->input, &mpctx->opts->input);
+ mp_input_uninit(mpctx->input);
osd_free(mpctx->osd);
@@ -585,10 +585,6 @@ 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.
- if (mpctx->mconfig)
- m_config_free(mpctx->mconfig);
- mpctx->mconfig = NULL;
-
talloc_free(mpctx);
#ifdef CONFIG_COCOA
@@ -661,7 +657,7 @@ static void load_per_protocol_config(m_config_t *conf, const char * const file)
sprintf(protocol, "%s%s", PROFILE_CFG_PROTOCOL, file);
protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) - strlen(str)] = '\0';
- p = m_config_get_profile(conf, protocol);
+ p = m_config_get_profile0(conf, protocol);
if (p) {
mp_tmsg(MSGT_CPLAYER, MSGL_INFO,
"Loading protocol-related profile '%s'\n", protocol);
@@ -684,7 +680,7 @@ static void load_per_extension_config(m_config_t *conf, const char * const file)
sprintf(extension, PROFILE_CFG_EXTENSION);
strncat(extension, ++str, 7);
- p = m_config_get_profile(conf, extension);
+ p = m_config_get_profile0(conf, extension);
if (p) {
mp_tmsg(MSGT_CPLAYER, MSGL_INFO,
"Loading extension-related profile '%s'\n", extension);
@@ -704,7 +700,7 @@ static void load_per_output_config(m_config_t *conf, char *cfg, char *out)
return;
sprintf(profile, "%s%s", cfg, out);
- p = m_config_get_profile(conf, profile);
+ p = m_config_get_profile0(conf, profile);
if (p) {
mp_tmsg(MSGT_CPLAYER, MSGL_INFO,
"Loading extension-related profile '%s'\n", profile);
@@ -3872,7 +3868,7 @@ static int read_keys(void *ctx, int fd)
static void init_input(struct MPContext *mpctx)
{
- mpctx->input = mp_input_init(&mpctx->opts->input, mpctx->opts->load_config);
+ mpctx->input = mp_input_init(mpctx->opts);
if (mpctx->opts->slave_mode)
mp_input_add_cmd_fd(mpctx->input, 0, USE_FD0_CMD_SELECT, MP_INPUT_SLAVE_CMD_FUNC, NULL);
else if (mpctx->opts->consolecontrols)
@@ -4597,7 +4593,6 @@ static int mpv_main(int argc, char *argv[])
struct MPContext *mpctx = talloc(NULL, MPContext);
*mpctx = (struct MPContext){
- .opts = talloc(mpctx, struct MPOpts),
.last_dvb_step = 1,
.terminal_osd_text = talloc_strdup(mpctx, ""),
.playlist = talloc_struct(mpctx, struct playlist, {0}),
@@ -4607,12 +4602,14 @@ static int mpv_main(int argc, char *argv[])
init_libav();
screenshot_init(mpctx);
- struct MPOpts *opts = mpctx->opts;
// Create the config context and register the options
- *opts = mp_default_opts;
- mpctx->mconfig = m_config_new(opts, cfg_include);
- m_config_register_options(mpctx->mconfig, mp_opts);
- mp_input_register_options(mpctx->mconfig);
+ mpctx->mconfig = m_config_new(mpctx, sizeof(struct MPOpts),
+ &mp_default_opts, mp_opts);
+ mpctx->opts = mpctx->mconfig->optstruct;
+ mpctx->mconfig->includefunc = cfg_include;
+ mpctx->mconfig->use_profiles = true;
+
+ struct MPOpts *opts = mpctx->opts;
// Preparse the command line
m_config_preparse_command_line(mpctx->mconfig, argc, argv);