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).
This commit is contained in:
wm4 2015-05-07 21:26:11 +02:00
parent 036a49478f
commit 3477088741
3 changed files with 34 additions and 24 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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"),