diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/external_files.c | 27 | ||||
-rw-r--r-- | player/external_files.h | 4 | ||||
-rw-r--r-- | player/loadfile.c | 3 | ||||
-rw-r--r-- | player/main.c | 10 |
4 files changed, 23 insertions, 21 deletions
diff --git a/player/external_files.c b/player/external_files.c index 4798439e3e..ab7f05b270 100644 --- a/player/external_files.c +++ b/player/external_files.c @@ -104,13 +104,12 @@ static struct bstr guess_lang_from_filename(struct bstr name) return (struct bstr){name.start + i + 1, n}; } -static void append_dir_subtitles(struct mpv_global *global, +static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, struct subfn **slist, int *nsub, struct bstr path, const char *fname, int limit_fuzziness, int limit_type) { void *tmpmem = talloc_new(NULL); - struct MPOpts *opts = global->opts; struct mp_log *log = mp_log_new(tmpmem, global->log, "find_files"); struct bstr f_fbname = bstr0(mp_basename(fname)); @@ -253,16 +252,16 @@ static void filter_subidx(struct subfn **slist, int *nsub) } } -static void load_paths(struct mpv_global *global, struct subfn **slist, - int *nsubs, const char *fname, char **paths, - char *cfg_path, int type) +static void load_paths(struct mpv_global *global, struct MPOpts *opts, + struct subfn **slist, int *nsubs, const char *fname, + char **paths, char *cfg_path, int type) { for (int i = 0; paths && paths[i]; i++) { char *expanded_path = mp_get_user_path(NULL, global, paths[i]); char *path = mp_path_join_bstr( *slist, mp_dirname(fname), bstr0(expanded_path ? expanded_path : paths[i])); - append_dir_subtitles(global, slist, nsubs, bstr0(path), + append_dir_subtitles(global, opts, slist, nsubs, bstr0(path), fname, 0, type); talloc_free(expanded_path); } @@ -270,32 +269,32 @@ static void load_paths(struct mpv_global *global, struct subfn **slist, // Load subtitles in ~/.mpv/sub (or similar) limiting sub fuzziness char *mp_subdir = mp_find_config_file(NULL, global, cfg_path); if (mp_subdir) { - append_dir_subtitles(global, slist, nsubs, bstr0(mp_subdir), fname, 1, - type); + append_dir_subtitles(global, opts, slist, nsubs, bstr0(mp_subdir), + fname, 1, type); } talloc_free(mp_subdir); } // Return a list of subtitles and audio files found, sorted by priority. // Last element is terminated with a fname==NULL entry. -struct subfn *find_external_files(struct mpv_global *global, const char *fname) +struct subfn *find_external_files(struct mpv_global *global, const char *fname, + struct MPOpts *opts) { - struct MPOpts *opts = global->opts; struct subfn *slist = talloc_array_ptrtype(NULL, slist, 1); int n = 0; // Load subtitles from current media directory - append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0, -1); + append_dir_subtitles(global, opts, &slist, &n, mp_dirname(fname), fname, 0, -1); // Load subtitles in dirs specified by sub-paths option if (opts->sub_auto >= 0) { - load_paths(global, &slist, &n, fname, opts->sub_paths, "sub", + load_paths(global, opts, &slist, &n, fname, opts->sub_paths, "sub", STREAM_SUB); } if (opts->audiofile_auto >= 0) { - load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio", - STREAM_AUDIO); + load_paths(global, opts, &slist, &n, fname, opts->audiofile_paths, + "audio", STREAM_AUDIO); } // Sort by name for filter_subidx() diff --git a/player/external_files.h b/player/external_files.h index 7d7d751332..d2de60ee5e 100644 --- a/player/external_files.h +++ b/player/external_files.h @@ -28,7 +28,9 @@ struct subfn { }; struct mpv_global; -struct subfn *find_external_files(struct mpv_global *global, const char *fname); +struct MPOpts; +struct subfn *find_external_files(struct mpv_global *global, const char *fname, + struct MPOpts *opts); bool mp_might_be_subtitle_file(const char *filename); diff --git a/player/loadfile.c b/player/loadfile.c index bc2886a5d6..f7fc86332c 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -824,7 +824,8 @@ void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel) &stream_filename) > 0) base_filename = talloc_steal(tmp, stream_filename); } - struct subfn *list = find_external_files(mpctx->global, base_filename); + struct subfn *list = find_external_files(mpctx->global, base_filename, + mpctx->opts); talloc_steal(tmp, list); int sc[STREAM_TYPE_COUNT] = {0}; diff --git a/player/main.c b/player/main.c index d94b61230e..0a11bcf7d2 100644 --- a/player/main.c +++ b/player/main.c @@ -117,7 +117,7 @@ void mp_update_logging(struct MPContext *mpctx, bool preinit) { bool had_log_file = mp_msg_has_log_file(mpctx->global); - mp_msg_update_msglevels(mpctx->global); + mp_msg_update_msglevels(mpctx->global, mpctx->opts); bool enable = mpctx->opts->use_terminal; bool enabled = cas_terminal_owner(mpctx, mpctx); @@ -303,8 +303,6 @@ struct MPContext *mp_create(void) m_config_parse(mpctx->mconfig, "", bstr0(def_config), NULL, 0); m_config_create_shadow(mpctx->mconfig); - mpctx->global->opts = mpctx->opts; - mpctx->input = mp_input_init(mpctx->global, mp_wakeup_core_cb, mpctx); screenshot_init(mpctx); command_init(mpctx); @@ -335,8 +333,10 @@ int mp_initialize(struct MPContext *mpctx, char **options) assert(!mpctx->initialized); // Preparse the command line, so we can init the terminal early. - if (options) - m_config_preparse_command_line(mpctx->mconfig, mpctx->global, options); + if (options) { + m_config_preparse_command_line(mpctx->mconfig, mpctx->global, + &opts->verbose, options); + } mp_init_paths(mpctx->global, opts); mp_update_logging(mpctx, true); |