summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-07 21:26:11 +0200
committerwm4 <wm4@nowhere>2015-05-07 21:26:11 +0200
commit34770887410cab45e2779d43a83aa4f6bdecf926 (patch)
tree2f61367ee2e4e736e9d4e64c8ea2ecff78f176e9
parent036a49478ff6cc19abfa06b7807bd4653eb9ce33 (diff)
downloadmpv-34770887410cab45e2779d43a83aa4f6bdecf926.tar.bz2
mpv-34770887410cab45e2779d43a83aa4f6bdecf926.tar.xz
player: use profiles for libmpv and encoding defaults
The client API (libmpv) and encoding (--o) have slightly different defaults from the command line player. Instead of doing a bunch of calls to set the options explicitly, use profiles. This is simpler and has the advantage that they can be listed on command line (instead of possibly forcing the user to find and read the code to know all the details).
-rw-r--r--libmpv/client.h2
-rw-r--r--player/client.c15
-rw-r--r--player/main.c41
3 files changed, 34 insertions, 24 deletions
diff --git a/libmpv/client.h b/libmpv/client.h
index a800043359..5a7a54ad67 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -369,6 +369,8 @@ const char *mpv_client_name(mpv_handle *ctx);
* if there are no more files to play on the internal playlist, instead of
* exiting. This is equivalent to the --idle option.
* - Disable parts of input handling.
+ * - Most of the different settings can be viewed with the command line player
+ * by running "mpv --show-profile=libmpv".
*
* All this assumes that API users want a mpv instance that is strictly
* isolated from the command line player's configuration, user settings, and
diff --git a/player/client.c b/player/client.c
index 43c7c07c60..4fba2912e7 100644
--- a/player/client.c
+++ b/player/client.c
@@ -466,20 +466,7 @@ mpv_handle *mpv_create(void)
if (ctx) {
ctx->owner = true;
ctx->fuzzy_initialized = true;
- // Set some defaults.
- mpv_set_option_string(ctx, "config", "no");
- mpv_set_option_string(ctx, "idle", "yes");
- mpv_set_option_string(ctx, "terminal", "no");
- mpv_set_option_string(ctx, "input-terminal", "no");
- mpv_set_option_string(ctx, "osc", "no");
- mpv_set_option_string(ctx, "ytdl", "no");
- mpv_set_option_string(ctx, "input-default-bindings", "no");
- mpv_set_option_string(ctx, "input-vo-keyboard", "no");
- mpv_set_option_string(ctx, "input-lirc", "no");
- mpv_set_option_string(ctx, "input-appleremote", "no");
- mpv_set_option_string(ctx, "input-media-keys", "no");
- mpv_set_option_string(ctx, "input-app-events", "no");
- mpv_set_option_string(ctx, "stop-playback-on-init-failure", "yes");
+ m_config_set_profile(mpctx->mconfig, "libmpv", 0);
} else {
mp_destroy(mpctx);
}
diff --git a/player/main.c b/player/main.c
index c227db7b1e..cb7fda3e49 100644
--- a/player/main.c
+++ b/player/main.c
@@ -100,7 +100,36 @@ static const char def_config[] =
"terminal=no\n"
"force-window=yes\n"
"idle=once\n"
- "screenshot-directory=~~desktop/\n";
+ "screenshot-directory=~~desktop/\n"
+ "\n"
+ "[libmpv]\n"
+ "config=no\n"
+ "idle=yes\n"
+ "terminal=no\n"
+ "input-terminal=no\n"
+ "osc=no\n"
+ "ytdl=no\n"
+ "input-default-bindings=no\n"
+ "input-vo-keyboard=no\n"
+ "input-lirc=no\n"
+ "input-appleremote=no\n"
+ "input-media-keys=no\n"
+ "input-app-events=no\n"
+ "stop-playback-on-init-failure=yes\n"
+#if HAVE_ENCODING
+ "\n"
+ "[encoding]\n"
+ "vo=lavc\n"
+ "ao=lavc\n"
+ "keep-open=no\n"
+ "force-window=no\n"
+ "gapless-audio=yes\n"
+ "resume-playback=no\n"
+ "load-scripts=no\n"
+ "osc=no\n"
+ "framedrop=no\n"
+#endif
+;
static pthread_mutex_t terminal_owner_lock = PTHREAD_MUTEX_INITIALIZER;
static struct MPContext *terminal_owner;
@@ -402,15 +431,7 @@ int mp_initialize(struct MPContext *mpctx, char **options)
MP_INFO(mpctx, "Encoding initialization failed.");
return -1;
}
- m_config_set_option0(mpctx->mconfig, "vo", "lavc");
- m_config_set_option0(mpctx->mconfig, "ao", "lavc");
- m_config_set_option0(mpctx->mconfig, "keep-open", "no");
- m_config_set_option0(mpctx->mconfig, "force-window", "no");
- m_config_set_option0(mpctx->mconfig, "gapless-audio", "yes");
- m_config_set_option0(mpctx->mconfig, "resume-playback", "no");
- m_config_set_option0(mpctx->mconfig, "load-scripts", "no");
- m_config_set_option0(mpctx->mconfig, "osc", "no");
- m_config_set_option0(mpctx->mconfig, "framedrop", "no");
+ m_config_set_profile(mpctx->mconfig, "encoding", 0);
// never use auto
if (!opts->audio_output_channels.num) {
m_config_set_option_ext(mpctx->mconfig, bstr0("audio-channels"),