summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/audio.c2
-rw-r--r--player/command.c13
-rw-r--r--player/command.h3
-rw-r--r--player/configfiles.c101
-rw-r--r--player/core.h19
-rw-r--r--player/loadfile.c76
-rw-r--r--player/lua.c12
-rw-r--r--player/main.c107
-rw-r--r--player/osd.c6
-rw-r--r--player/playloop.c2
-rw-r--r--player/screenshot.c6
-rw-r--r--player/sub.c2
-rw-r--r--player/timeline/tl_cue.c24
-rw-r--r--player/timeline/tl_matroska.c58
-rw-r--r--player/timeline/tl_mpv_edl.c13
-rw-r--r--player/video.c4
16 files changed, 229 insertions, 219 deletions
diff --git a/player/audio.c b/player/audio.c
index ab91834aa8..64160e0cd7 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -114,6 +114,8 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->initialized_flags |= INITIALIZED_ACODEC;
assert(!mpctx->d_audio);
mpctx->d_audio = talloc_zero(NULL, struct dec_audio);
+ mpctx->d_audio->log = mp_log_new(mpctx->d_audio, mpctx->log, "!ad");
+ mpctx->d_audio->global = mpctx->global;
mpctx->d_audio->opts = opts;
mpctx->d_audio->header = sh;
if (!audio_init_best_codec(mpctx->d_audio, opts->audio_decoders))
diff --git a/player/command.c b/player/command.c
index 9247887c31..a7ded72836 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2040,7 +2040,7 @@ const struct m_option *mp_get_property_list(void)
int mp_property_do(const char *name, int action, void *val,
struct MPContext *ctx)
{
- return m_property_do(mp_properties, name, action, val, ctx);
+ return m_property_do(ctx->log, mp_properties, name, action, val, ctx);
}
char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
@@ -2048,9 +2048,9 @@ char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
return m_properties_expand_string(mp_properties, str, mpctx);
}
-void property_print_help(void)
+void property_print_help(struct mp_log *log)
{
- m_properties_print_help_list(mp_properties);
+ m_properties_print_help_list(log, mp_properties);
}
@@ -2294,7 +2294,8 @@ static int edit_filters(struct MPContext *mpctx, enum stream_type mediatype,
struct m_obj_settings *new_chain = NULL;
m_option_copy(co->opt, &new_chain, co->data);
- int r = m_option_parse(co->opt, bstr0(optname), bstr0(arg), &new_chain);
+ int r = m_option_parse(mpctx->log, co->opt, bstr0(optname), bstr0(arg),
+ &new_chain);
if (r >= 0)
r = set_filters(mpctx, mediatype, new_chain);
@@ -2791,7 +2792,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_LOADLIST: {
char *filename = cmd->args[0].v.s;
bool append = cmd->args[1].v.i;
- struct playlist *pl = playlist_parse_file(filename, opts);
+ struct playlist *pl = playlist_parse_file(filename, mpctx->global);
if (pl) {
if (!append)
playlist_clear(mpctx->playlist);
@@ -2800,7 +2801,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (!append && mpctx->playlist->first) {
struct playlist_entry *e =
- mp_resume_playlist(mpctx->playlist, opts);
+ mp_check_playlist_resume(mpctx, mpctx->playlist);
mp_set_playlist_entry(mpctx, e ? e : mpctx->playlist->first);
}
} else {
diff --git a/player/command.h b/player/command.h
index d3469fc131..56eb30f859 100644
--- a/player/command.h
+++ b/player/command.h
@@ -21,13 +21,14 @@
struct MPContext;
struct mp_cmd;
+struct mp_log;
void command_init(struct MPContext *mpctx);
void command_uninit(struct MPContext *mpctx);
void run_command(struct MPContext *mpctx, struct mp_cmd *cmd);
char *mp_property_expand_string(struct MPContext *mpctx, const char *str);
-void property_print_help(void);
+void property_print_help(struct mp_log *log);
int mp_property_do(const char* name, int action, void* val,
struct MPContext *mpctx);
diff --git a/player/configfiles.c b/player/configfiles.c
index 37d081b953..87da9d9260 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -55,8 +55,8 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
return true;
if (!m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mpv.conf", 0) < 0)
return false;
- mp_mk_config_dir(NULL);
- if ((conffile = mp_find_user_config_file("config")) == NULL)
+ mp_mk_config_dir(mpctx->global, NULL);
+ if (!(conffile = mp_find_user_config_file(NULL, mpctx->global, "config")))
MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
else {
int fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666);
@@ -78,9 +78,10 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
#define PROFILE_CFG_PROTOCOL "protocol."
-void mp_load_per_protocol_config(m_config_t *conf, const char * const file)
+static void mp_load_per_protocol_config(struct MPContext *mpctx)
{
char *str;
+ const char *file = mpctx->filename;
char protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) + 1];
m_profile_t *p;
@@ -93,19 +94,19 @@ void mp_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_profile0(conf, protocol);
+ p = m_config_get_profile0(mpctx->mconfig, protocol);
if (p) {
- mp_msg(MSGT_CPLAYER, MSGL_INFO,
- "Loading protocol-related profile '%s'\n", protocol);
- m_config_set_profile(conf, p, FILE_LOCAL_FLAGS);
+ MP_INFO(mpctx, "Loading protocol-related profile '%s'\n", protocol);
+ m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS);
}
}
#define PROFILE_CFG_EXTENSION "extension."
-void mp_load_per_extension_config(m_config_t *conf, const char * const file)
+static void mp_load_per_extension_config(struct MPContext *mpctx)
{
char *str;
+ const char *file = mpctx->filename;
char extension[strlen(PROFILE_CFG_EXTENSION) + 8];
m_profile_t *p;
@@ -116,15 +117,14 @@ void mp_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_profile0(conf, extension);
+ p = m_config_get_profile0(mpctx->mconfig, extension);
if (p) {
- mp_msg(MSGT_CPLAYER, MSGL_INFO,
- "Loading extension-related profile '%s'\n", extension);
- m_config_set_profile(conf, p, FILE_LOCAL_FLAGS);
+ MP_INFO(mpctx, "Loading extension-related profile '%s'\n", extension);
+ m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS);
}
}
-void mp_load_per_output_config(m_config_t *conf, char *cfg, char *out)
+static void mp_load_per_output_config(struct MPContext *mpctx, char *cfg, char *out)
{
char profile[strlen(cfg) + strlen(out) + 1];
m_profile_t *p;
@@ -133,54 +133,68 @@ void mp_load_per_output_config(m_config_t *conf, char *cfg, char *out)
return;
sprintf(profile, "%s%s", cfg, out);
- p = m_config_get_profile0(conf, profile);
+ p = m_config_get_profile0(mpctx->mconfig, profile);
if (p) {
- mp_msg(MSGT_CPLAYER, MSGL_INFO,
- "Loading extension-related profile '%s'\n", profile);
- m_config_set_profile(conf, p, FILE_LOCAL_FLAGS);
+ MP_INFO(mpctx, "Loading extension-related profile '%s'\n", profile);
+ m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS);
}
}
+void mp_load_auto_profiles(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = mpctx->opts;
+
+ mp_load_per_protocol_config(mpctx);
+ mp_load_per_extension_config(mpctx);
+ mp_load_per_file_config(mpctx);
+
+ if (opts->vo.video_driver_list)
+ mp_load_per_output_config(mpctx, "vo.", opts->vo.video_driver_list[0].name);
+ if (opts->audio_driver_list)
+ mp_load_per_output_config(mpctx, "ao.", opts->audio_driver_list[0].name);
+}
+
/**
* Tries to load a config file (in file local mode)
* @return 0 if file was not found, 1 otherwise
*/
-static int try_load_config(m_config_t *conf, const char *file, int flags)
+static int try_load_config(struct MPContext *mpctx, const char *file, int flags)
{
if (!mp_path_exists(file))
return 0;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file);
- m_config_parse_config_file(conf, file, flags);
+ MP_INFO(mpctx, "Loading config '%s'\n", file);
+ m_config_parse_config_file(mpctx->mconfig, file, flags);
return 1;
}
-void mp_load_per_file_config(m_config_t *conf, const char * const file,
- bool search_file_dir)
+void mp_load_per_file_config(struct MPContext *mpctx)
{
+ struct MPOpts *opts = mpctx->opts;
char *confpath;
char cfg[MP_PATH_MAX];
const char *name;
+ const char *file = mpctx->filename;
if (strlen(file) > MP_PATH_MAX - 14) {
- mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, "
+ MP_WARN(mpctx, "Filename is too long, "
"can not load file or directory specific config files\n");
return;
}
sprintf(cfg, "%s.conf", file);
name = mp_basename(cfg);
- if (search_file_dir) {
+ if (opts->use_filedir_conf) {
char dircfg[MP_PATH_MAX];
strcpy(dircfg, cfg);
strcpy(dircfg + (name - cfg), "mpv.conf");
- try_load_config(conf, dircfg, FILE_LOCAL_FLAGS);
+ try_load_config(mpctx, dircfg, FILE_LOCAL_FLAGS);
- if (try_load_config(conf, cfg, FILE_LOCAL_FLAGS))
+ if (try_load_config(mpctx, cfg, FILE_LOCAL_FLAGS))
return;
}
- if ((confpath = mp_find_user_config_file(name)) != NULL) {
- try_load_config(conf, confpath, FILE_LOCAL_FLAGS);
+ if ((confpath = mp_find_user_config_file(NULL, mpctx->global, name))) {
+ try_load_config(mpctx, confpath, FILE_LOCAL_FLAGS);
talloc_free(confpath);
}
@@ -188,8 +202,8 @@ void mp_load_per_file_config(m_config_t *conf, const char * const file,
#define MP_WATCH_LATER_CONF "watch_later"
-char *mp_get_playback_resume_config_filename(const char *fname,
- struct MPOpts *opts)
+static char *mp_get_playback_resume_config_filename(struct mpv_global *global,
+ const char *fname)
{
char *res = NULL;
void *tmp = talloc_new(NULL);
@@ -218,7 +232,7 @@ char *mp_get_playback_resume_config_filename(const char *fname,
conf = talloc_asprintf(tmp, "%s/%s", MP_WATCH_LATER_CONF, conf);
- res = mp_find_user_config_file(conf);
+ res = mp_find_user_config_file(NULL, global, conf);
exit:
talloc_free(tmp);
@@ -284,10 +298,10 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
if (pos == MP_NOPTS_VALUE)
goto exit;
- mp_mk_config_dir(MP_WATCH_LATER_CONF);
+ mp_mk_config_dir(mpctx->global, MP_WATCH_LATER_CONF);
- char *conffile = mp_get_playback_resume_config_filename(mpctx->filename,
- mpctx->opts);
+ char *conffile = mp_get_playback_resume_config_filename(mpctx->global,
+ mpctx->filename);
talloc_steal(tmp, conffile);
if (!conffile)
goto exit;
@@ -318,15 +332,15 @@ exit:
talloc_free(tmp);
}
-void mp_load_playback_resume(m_config_t *conf, const char *file)
+void mp_load_playback_resume(struct MPContext *mpctx, const char *file)
{
- char *fname = mp_get_playback_resume_config_filename(file, conf->optstruct);
+ char *fname = mp_get_playback_resume_config_filename(mpctx->global, file);
if (fname && mp_path_exists(fname)) {
// Never apply the saved start position to following files
- m_config_backup_opt(conf, "start");
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "Resuming playback. This behavior can "
+ m_config_backup_opt(mpctx->mconfig, "start");
+ MP_INFO(mpctx, "Resuming playback. This behavior can "
"be disabled with --no-resume-playback.\n");
- try_load_config(conf, fname, M_SETOPT_PRESERVE_CMDLINE);
+ try_load_config(mpctx, fname, M_SETOPT_PRESERVE_CMDLINE);
unlink(fname);
}
talloc_free(fname);
@@ -337,13 +351,14 @@ void mp_load_playback_resume(m_config_t *conf, const char *file)
// resume file for them, this is simpler, and also has the nice property
// that appending to a playlist doesn't interfere with resuming (especially
// if the playlist comes from the command line).
-struct playlist_entry *mp_resume_playlist(struct playlist *playlist,
- struct MPOpts *opts)
+struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
+ struct playlist *playlist)
{
- if (!opts->position_resume)
+ if (!mpctx->opts->position_resume)
return NULL;
for (struct playlist_entry *e = playlist->first; e; e = e->next) {
- char *conf = mp_get_playback_resume_config_filename(e->filename, opts);
+ char *conf = mp_get_playback_resume_config_filename(mpctx->global,
+ e->filename);
bool exists = conf && mp_path_exists(conf);
talloc_free(conf);
if (exists)
diff --git a/player/core.h b/player/core.h
index a344b92ac3..711c99840b 100644
--- a/player/core.h
+++ b/player/core.h
@@ -147,6 +147,7 @@ typedef struct MPContext {
struct mpv_global *global;
struct MPOpts *opts;
struct mp_log *log;
+ struct mp_log *statusline;
struct m_config *mconfig;
struct input_ctx *input;
struct osd_state *osd;
@@ -313,6 +314,7 @@ typedef struct MPContext {
*/
struct ass_renderer *ass_renderer;
struct ass_library *ass_library;
+ struct mp_log *ass_log;
int last_dvb_step;
@@ -347,17 +349,12 @@ void clear_audio_decode_buffers(struct MPContext *mpctx);
// configfiles.c
bool mp_parse_cfgfiles(struct MPContext *mpctx);
-char *mp_get_playback_resume_config_filename(const char *fname,
- struct MPOpts *opts);
-void mp_load_per_protocol_config(struct m_config *conf, const char * const file);
-void mp_load_per_extension_config(struct m_config *conf, const char * const file);
-void mp_load_per_output_config(struct m_config *conf, char *cfg, char *out);
-void mp_load_per_file_config(struct m_config *conf, const char * const file,
- bool search_file_dir);
-void mp_load_playback_resume(struct m_config *conf, const char *file);
+void mp_load_auto_profiles(struct MPContext *mpctx);
+void mp_load_per_file_config(struct MPContext *mpctx);
+void mp_load_playback_resume(struct MPContext *mpctx, const char *file);
void mp_write_watch_later_conf(struct MPContext *mpctx);
-struct playlist_entry *mp_resume_playlist(struct playlist *playlist,
- struct MPOpts *opts);
+struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
+ struct playlist *playlist);
// dvdnav.c
void mp_nav_init(struct MPContext *mpctx);
@@ -386,7 +383,7 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
void mp_play_files(struct MPContext *mpctx);
// main.c
-void mp_print_version(int always);
+void mp_print_version(struct mp_log *log, int always);
// misc.c
double get_start_time(struct MPContext *mpctx);
diff --git a/player/loadfile.c b/player/loadfile.c
index d9518c1918..46238c2d2d 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -220,30 +220,30 @@ static void print_stream(struct MPContext *mpctx, struct track *t)
if (!iid)
return;
int id = t->user_tid;
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_%s_ID=%d\n", iid, id);
+ MP_SMODE(mpctx, "ID_%s_ID=%d\n", iid, id);
if (t->title)
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_%s_%d_NAME=%s\n", iid, id, t->title);
+ MP_SMODE(mpctx, "ID_%s_%d_NAME=%s\n", iid, id, t->title);
if (t->lang)
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_%s_%d_LANG=%s\n", iid, id, t->lang);
+ MP_SMODE(mpctx, "ID_%s_%d_LANG=%s\n", iid, id, t->lang);
}
static void print_file_properties(struct MPContext *mpctx)
{
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILENAME=%s\n", mpctx->filename);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ MP_SMODE(mpctx, "ID_FILENAME=%s\n", mpctx->filename);
+ MP_SMODE(mpctx,
"ID_LENGTH=%.2f\n", get_time_length(mpctx));
int chapter_count = get_chapter_count(mpctx);
if (chapter_count >= 0) {
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTERS=%d\n", chapter_count);
+ MP_SMODE(mpctx, "ID_CHAPTERS=%d\n", chapter_count);
for (int i = 0; i < chapter_count; i++) {
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTER_ID=%d\n", i);
+ MP_SMODE(mpctx, "ID_CHAPTER_ID=%d\n", i);
// print in milliseconds
double time = chapter_start_time(mpctx, i) * 1000.0;
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTER_%d_START=%"PRId64"\n",
+ MP_SMODE(mpctx, "ID_CHAPTER_%d_START=%"PRId64"\n",
i, (int64_t)(time < 0 ? -1 : time));
char *name = chapter_name(mpctx, i);
if (name) {
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CHAPTER_%d_NAME=%s\n", i,
+ MP_SMODE(mpctx, "ID_CHAPTER_%d_NAME=%s\n", i,
name);
talloc_free(name);
}
@@ -693,7 +693,7 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
if (stream_control(mpctx->stream, STREAM_CTRL_GET_BASE_FILENAME,
&stream_filename) > 0)
base_filename = talloc_steal(tmp, stream_filename);
- struct subfn *list = find_text_subtitles(mpctx->opts, base_filename);
+ struct subfn *list = find_text_subtitles(mpctx->global, base_filename);
talloc_steal(tmp, list);
for (int i = 0; list && list[i].fname; i++) {
char *filename = list[i].fname;
@@ -724,7 +724,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
char *disp_filename = filename;
if (strncmp(disp_filename, "memory://", 9) == 0)
disp_filename = "memory://"; // avoid noise
- struct stream *stream = stream_open(filename, mpctx->opts);
+ struct stream *stream = stream_open(filename, mpctx->global);
if (!stream)
goto err_out;
stream_enable_cache_percent(&stream, stream_cache,
@@ -735,7 +735,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
.ass_library = mpctx->ass_library, // demux_libass requires it
};
struct demuxer *demuxer =
- demux_open(stream, demuxer_name, &params, mpctx->opts);
+ demux_open(stream, demuxer_name, &params, mpctx->global);
if (!demuxer) {
free_stream(stream);
goto err_out;
@@ -842,19 +842,21 @@ static void init_sub_renderer(struct MPContext *mpctx)
assert(!mpctx->ass_renderer);
mpctx->ass_renderer = ass_renderer_init(mpctx->ass_library);
- if (mpctx->ass_renderer)
- mp_ass_configure_fonts(mpctx->ass_renderer, mpctx->opts->sub_text_style);
+ if (mpctx->ass_renderer) {
+ mp_ass_configure_fonts(mpctx->ass_renderer, mpctx->opts->sub_text_style,
+ mpctx->global, mpctx->ass_log);
+ }
mpctx->initialized_flags |= INITIALIZED_LIBASS;
#endif
}
static struct mp_resolve_result *resolve_url(const char *filename,
- struct MPOpts *opts)
+ struct mpv_global *global)
{
if (!mp_is_url(bstr0(filename)))
return NULL;
#if HAVE_LIBQUVI
- return mp_resolve_quvi(filename, opts);
+ return mp_resolve_quvi(filename, global);
#else
return NULL;
#endif
@@ -863,29 +865,29 @@ static struct mp_resolve_result *resolve_url(const char *filename,
static void print_resolve_contents(struct mp_log *log,
struct mp_resolve_result *res)
{
- mp_msg_log(log, MSGL_V, "Resolve:\n");
- mp_msg_log(log, MSGL_V, " title: %s\n", res->title);
- mp_msg_log(log, MSGL_V, " url: %s\n", res->url);
+ mp_msg(log, MSGL_V, "Resolve:\n");
+ mp_msg(log, MSGL_V, " title: %s\n", res->title);
+ mp_msg(log, MSGL_V, " url: %s\n", res->url);
for (int n = 0; n < res->num_srcs; n++) {
- mp_msg_log(log, MSGL_V, " source %d:\n", n);
+ mp_msg(log, MSGL_V, " source %d:\n", n);
if (res->srcs[n]->url)
- mp_msg_log(log, MSGL_V, " url: %s\n", res->srcs[n]->url);
+ mp_msg(log, MSGL_V, " url: %s\n", res->srcs[n]->url);
if (res->srcs[n]->encid)
- mp_msg_log(log, MSGL_V, " encid: %s\n", res->srcs[n]->encid);
+ mp_msg(log, MSGL_V, " encid: %s\n", res->srcs[n]->encid);
}
for (int n = 0; n < res->num_subs; n++) {
- mp_msg_log(log, MSGL_V, " subtitle %d:\n", n);
+ mp_msg(log, MSGL_V, " subtitle %d:\n", n);
if (res->subs[n]->url)
- mp_msg_log(log, MSGL_V, " url: %s\n", res->subs[n]->url);
+ mp_msg(log, MSGL_V, " url: %s\n", res->subs[n]->url);
if (res->subs[n]->lang)
- mp_msg_log(log, MSGL_V, " lang: %s\n", res->subs[n]->lang);
+ mp_msg(log, MSGL_V, " lang: %s\n", res->subs[n]->lang);
if (res->subs[n]->data) {
- mp_msg_log(log, MSGL_V, " data: %zd bytes\n",
+ mp_msg(log, MSGL_V, " data: %zd bytes\n",
strlen(res->subs[n]->data));
}
}
if (res->playlist) {
- mp_msg_log(log, MSGL_V, " playlist with %d entries\n",
+ mp_msg(log, MSGL_V, " playlist with %d entries\n",
playlist_entry_count(res->playlist));
}
}
@@ -999,19 +1001,10 @@ static void play_current_file(struct MPContext *mpctx)
}
}
- mp_load_per_protocol_config(mpctx->mconfig, mpctx->filename);
- mp_load_per_extension_config(mpctx->mconfig, mpctx->filename);
- mp_load_per_file_config(mpctx->mconfig, mpctx->filename, opts->use_filedir_conf);
-
- if (opts->vo.video_driver_list)
- mp_load_per_output_config(mpctx->mconfig, "vo.",
- opts->vo.video_driver_list[0].name);
- if (opts->audio_driver_list)
- mp_load_per_output_config(mpctx->mconfig, "ao.",
- opts->audio_driver_list[0].name);
+ mp_load_auto_profiles(mpctx);
if (opts->position_resume)
- mp_load_playback_resume(mpctx->mconfig, mpctx->filename);
+ mp_load_playback_resume(mpctx, mpctx->filename);
load_per_file_options(mpctx->mconfig, mpctx->playlist->current->params,
mpctx->playlist->current->num_params);
@@ -1035,7 +1028,7 @@ static void play_current_file(struct MPContext *mpctx)
assert(mpctx->d_sub == NULL);
char *stream_filename = mpctx->filename;
- mpctx->resolve_result = resolve_url(stream_filename, opts);
+ mpctx->resolve_result = resolve_url(stream_filename, mpctx->global);
if (mpctx->resolve_result) {
print_resolve_contents(mpctx->log, mpctx->resolve_result);
if (mpctx->resolve_result->playlist) {
@@ -1044,7 +1037,7 @@ static void play_current_file(struct MPContext *mpctx)
}
stream_filename = mpctx->resolve_result->url;
}
- mpctx->stream = stream_open(stream_filename, opts);
+ mpctx->stream = stream_open(stream_filename, mpctx->global);
if (!mpctx->stream) { // error...
demux_was_interrupted(mpctx);
goto terminate_playback;
@@ -1081,7 +1074,8 @@ goto_reopen_demuxer: ;
mpctx->audio_delay = opts->audio_delay;
- mpctx->demuxer = demux_open(mpctx->stream, opts->demuxer_name, NULL, opts);
+ mpctx->demuxer = demux_open(mpctx->stream, opts->demuxer_name, NULL,
+ mpctx->global);
mpctx->master_demuxer = mpctx->demuxer;
if (!mpctx->demuxer) {
MP_ERR(mpctx, "Failed to recognize file format.\n");
diff --git a/player/lua.c b/player/lua.c
index 5a3ec1db82..d6e44d9c18 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -260,7 +260,7 @@ static const char *log_level[] = {
[MSGL_WARN] = "warn",
[MSGL_INFO] = "info",
[MSGL_V] = "verbose",
- [MSGL_DBG2] = "debug",
+ [MSGL_DEBUG] = "debug",
};
static int script_log(lua_State *L)
@@ -287,18 +287,19 @@ static int script_log(lua_State *L)
const char *s = lua_tostring(L, -1);
if (s == NULL)
return luaL_error(L, "Invalid argument");
- mp_msg_log(ctx->log, msgl, "%s%s", s, i > 0 ? " " : "");
+ mp_msg(ctx->log, msgl, "%s%s", s, i > 0 ? " " : "");
lua_pop(L, 1); // args... tostring
}
- mp_msg_log(ctx->log, msgl, "\n");
+ mp_msg(ctx->log, msgl, "\n");
return 0;
}
static int script_find_config_file(lua_State *L)
{
+ struct MPContext *mpctx = get_mpctx(L);
const char *s = luaL_checkstring(L, 1);
- char *path = mp_find_user_config_file(s);
+ char *path = mp_find_user_config_file(NULL, mpctx->global, s);
if (path) {
lua_pushstring(L, path);
} else {
@@ -414,14 +415,13 @@ static int script_property_list(lua_State *L)
static int script_property_string(lua_State *L)
{
- const struct m_option *props = mp_get_property_list();
struct MPContext *mpctx = get_mpctx(L);
const char *name = luaL_checkstring(L, 1);
int type = lua_tointeger(L, lua_upvalueindex(1))
? M_PROPERTY_PRINT : M_PROPERTY_GET_STRING;
char *result = NULL;
- if (m_property_do(props, name, type, &result, mpctx) >= 0 && result) {
+ if (mp_property_do(name, type, &result, mpctx) >= 0 && result) {
lua_pushstring(L, result);
talloc_free(result);
return 1;
diff --git a/player/main.c b/player/main.c
index a1d56df5f0..5183f56ea3 100644
--- a/player/main.c
+++ b/player/main.c
@@ -94,13 +94,13 @@ const char mp_help_text[] =
" --list-options list all mpv options\n"
"\n";
-void mp_print_version(int always)
+void mp_print_version(struct mp_log *log, int always)
{
int v = always ? MSGL_INFO : MSGL_V;
- mp_msg(MSGT_CPLAYER, v,
+ mp_msg(log, v,
"%s (C) 2000-2013 mpv/MPlayer/mplayer2 projects\n built on %s\n", mplayer_version, mplayer_builddate);
- print_libav_versions(v);
- mp_msg(MSGT_CPLAYER, v, "\n");
+ print_libav_versions(log, v);
+ mp_msg(log, v, "\n");
}
static MP_NORETURN void exit_player(struct MPContext *mpctx,
@@ -140,6 +140,7 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx,
#endif
getch2_disable();
+ uninit_libav(mpctx->global);
if (how != EXIT_NONE) {
const char *reason;
@@ -194,22 +195,23 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx,
static bool handle_help_options(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
+ struct mp_log *log = mpctx->log;
int opt_exit = 0;
if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) {
struct mp_decoder_list *list = audio_decoder_list();
- mp_print_decoders(MSGT_CPLAYER, MSGL_INFO, "Audio decoders:", list);
+ mp_print_decoders(log, MSGL_INFO, "Audio decoders:", list);
talloc_free(list);
opt_exit = 1;
}
if (opts->video_decoders && strcmp(opts->video_decoders, "help") == 0) {
struct mp_decoder_list *list = video_decoder_list();
- mp_print_decoders(MSGT_CPLAYER, MSGL_INFO, "Video decoders:", list);
+ mp_print_decoders(log, MSGL_INFO, "Video decoders:", list);
talloc_free(list);
opt_exit = 1;
}
#if HAVE_X11
if (opts->vo.fstype_list && strcmp(opts->vo.fstype_list[0], "help") == 0) {
- fstype_help();
+ fstype_help(log);
MP_INFO(mpctx, "\n");
opt_exit = 1;
}
@@ -217,16 +219,16 @@ static bool handle_help_options(struct MPContext *mpctx)
if ((opts->demuxer_name && strcmp(opts->demuxer_name, "help") == 0) ||
(opts->audio_demuxer_name && strcmp(opts->audio_demuxer_name, "help") == 0) ||
(opts->sub_demuxer_name && strcmp(opts->sub_demuxer_name, "help") == 0)) {
- demuxer_help();
+ demuxer_help(log);
MP_INFO(mpctx, "\n");
opt_exit = 1;
}
if (opts->list_properties) {
- property_print_help();
+ property_print_help(log);
opt_exit = 1;
}
#if HAVE_ENCODING
- if (encode_lavc_showhelp(mpctx->opts))
+ if (encode_lavc_showhelp(log, &opts->encode_output))
opt_exit = 1;
#endif
return opt_exit;
@@ -264,36 +266,15 @@ static void osdep_preinit(int *p_argc, char ***p_argv)
SetErrorMode(0x8003);
#endif
- load_termcap(NULL); // load key-codes
+ terminal_init();
mp_time_init();
}
-static int read_keys(void *ctx, int fd)
+static int cfg_include(void *ctx, char *filename, int flags)
{
- if (getch2(ctx))
- return MP_INPUT_NOTHING;
- return MP_INPUT_DEAD;
-}
-
-static void init_input(struct MPContext *mpctx)
-{
- mpctx->input = mp_input_init(mpctx->global);
- 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)
- mp_input_add_key_fd(mpctx->input, 0, 1, read_keys, NULL, mpctx->input);
- // Set the libstream interrupt callback
- stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input);
-
-#if HAVE_COCOA
- cocoa_set_input_context(mpctx->input);
-#endif
-}
-
-static int cfg_include(struct m_config *conf, char *filename, int flags)
-{
- return m_config_parse_config_file(conf, filename, flags);
+ struct MPContext *mpctx = ctx;
+ return m_config_parse_config_file(mpctx->mconfig, filename, flags);
}
static int mpv_main(int argc, char *argv[])
@@ -312,40 +293,47 @@ static int mpv_main(int argc, char *argv[])
.playlist = talloc_struct(mpctx, struct playlist, {0}),
};
+ mpctx->global = talloc_zero(mpctx, struct mpv_global);
+
+ // Nothing must call mp_msg*() and related before this
+ mp_msg_init(mpctx->global);
+ mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer");
+ mpctx->statusline = mp_log_new(mpctx, mpctx->log, "!statusline");
+
// Create the config context and register the options
- mpctx->mconfig = m_config_new(mpctx, sizeof(struct MPOpts),
+ mpctx->mconfig = m_config_new(mpctx, mpctx->log, sizeof(struct MPOpts),
&mp_default_opts, mp_opts);
mpctx->opts = mpctx->mconfig->optstruct;
mpctx->mconfig->includefunc = cfg_include;
+ mpctx->mconfig->includefunc_ctx = mpctx;
mpctx->mconfig->use_profiles = true;
mpctx->mconfig->is_toplevel = true;
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, "!cplayer");
+ char *verbose_env = getenv("MPV_VERBOSE");
+ if (verbose_env)
+ opts->verbose = atoi(verbose_env);
+ mp_msg_update_msglevels(mpctx->global);
- init_libav();
+ init_libav(mpctx->global);
GetCpuCaps(&gCpuCaps);
screenshot_init(mpctx);
- mpctx->mixer = mixer_init(mpctx, opts);
+ mpctx->mixer = mixer_init(mpctx, mpctx->global);
command_init(mpctx);
// Preparse the command line
- m_config_preparse_command_line(mpctx->mconfig, argc, argv);
+ m_config_preparse_command_line(mpctx->mconfig, mpctx->global, argc, argv);
+ mp_msg_update_msglevels(mpctx->global);
- mp_print_version(false);
+ mp_print_version(mpctx->log, false);
if (!mp_parse_cfgfiles(mpctx))
exit_player(mpctx, EXIT_ERROR);
int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
- argc, argv);
+ mpctx->global, argc, argv);
if (r < 0) {
if (r <= M_OPT_EXIT) {
exit_player(mpctx, EXIT_NONE);
@@ -354,6 +342,8 @@ static int mpv_main(int argc, char *argv[])
}
}
+ mp_msg_update_msglevels(mpctx->global);
+
if (handle_help_options(mpctx))
exit_player(mpctx, EXIT_NONE);
@@ -364,7 +354,7 @@ static int mpv_main(int argc, char *argv[])
MP_VERBOSE(mpctx, "\n");
if (!mpctx->playlist->first && !opts->player_idle_mode) {
- mp_print_version(true);
+ mp_print_version(mpctx->log, true);
MP_INFO(mpctx, "%s", mp_help_text);
exit_player(mpctx, EXIT_NONE);
}
@@ -373,11 +363,16 @@ static int mpv_main(int argc, char *argv[])
set_priority();
#endif
- init_input(mpctx