summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options/parse_commandline.c4
-rw-r--r--player/main.c21
2 files changed, 13 insertions, 12 deletions
diff --git a/options/parse_commandline.c b/options/parse_commandline.c
index 06a6cb639b..6898075430 100644
--- a/options/parse_commandline.c
+++ b/options/parse_commandline.c
@@ -142,7 +142,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files,
mode = GLOBAL;
- struct parse_state p = {config, argv + 1};
+ struct parse_state p = {config, argv};
while (split_opt(&p)) {
if (p.is_opt) {
int flags = M_SETOPT_FROM_CMDLINE;
@@ -286,7 +286,7 @@ void m_config_preparse_command_line(m_config_t *config, struct mpv_global *globa
// Hack to shut up parser error messages
mp_msg_mute(global, true);
- struct parse_state p = {config, argv + 1};
+ struct parse_state p = {config, argv};
while (split_opt_silent(&p) == 0) {
if (p.is_opt) {
// Ignore non-pre-parse options. They will be set later.
diff --git a/player/main.c b/player/main.c
index f4da0e4698..6d7e55d290 100644
--- a/player/main.c
+++ b/player/main.c
@@ -368,9 +368,9 @@ void wakeup_playloop(void *ctx)
// Finish mpctx initialization. This must be done after setting up all options.
// Some of the initializations depend on the options, and can't be changed or
// undone later.
-// If argv is not NULL, apply them as command line player arguments.
+// If options is not NULL, apply them as command line player arguments.
// Returns: <0 on error, 0 on success.
-int mp_initialize(struct MPContext *mpctx, char **argv)
+int mp_initialize(struct MPContext *mpctx, char **options)
{
struct MPOpts *opts = mpctx->opts;
@@ -384,15 +384,15 @@ int mp_initialize(struct MPContext *mpctx, char **argv)
update_logging(mpctx);
- if (argv) {
+ if (options) {
// Preparse the command line, so we can init the terminal early.
- m_config_preparse_command_line(mpctx->mconfig, mpctx->global, argv);
+ m_config_preparse_command_line(mpctx->mconfig, mpctx->global, options);
update_logging(mpctx);
- MP_VERBOSE(mpctx, "Command line:");
- for (int i = 0; argv[i]; i++)
- MP_VERBOSE(mpctx, " '%s'", argv[i]);
+ MP_VERBOSE(mpctx, "Command line options:");
+ for (int i = 0; options[i]; i++)
+ MP_VERBOSE(mpctx, " '%s'", options[i]);
MP_VERBOSE(mpctx, "\n");
}
@@ -401,9 +401,9 @@ int mp_initialize(struct MPContext *mpctx, char **argv)
mp_parse_cfgfiles(mpctx);
update_logging(mpctx);
- if (argv) {
+ if (options) {
int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
- mpctx->global, argv);
+ mpctx->global, options);
if (r < 0)
return r <= M_OPT_EXIT ? -2 : -1;
update_logging(mpctx);
@@ -515,7 +515,8 @@ int mpv_main(int argc, char *argv[])
if (verbose_env)
opts->verbose = atoi(verbose_env);
- int r = mp_initialize(mpctx, argv);
+ char **options = argv && argv[0] ? argv + 1 : NULL; // skips program name
+ int r = mp_initialize(mpctx, options);
if (r == -2) // help
return prepare_exit_cplayer(mpctx, EXIT_NONE);
if (r == -3) { // nothing to play