diff options
-rw-r--r-- | audio/decode/ad_lavc.c | 6 | ||||
-rw-r--r-- | common/global.h | 4 | ||||
-rw-r--r-- | common/msg.c | 11 | ||||
-rw-r--r-- | common/msg_control.h | 3 | ||||
-rw-r--r-- | filters/f_decoder_wrapper.c | 21 | ||||
-rw-r--r-- | input/input.c | 7 | ||||
-rw-r--r-- | input/ipc-unix.c | 7 | ||||
-rw-r--r-- | input/ipc-win.c | 5 | ||||
-rw-r--r-- | options/parse_commandline.c | 6 | ||||
-rw-r--r-- | options/parse_commandline.h | 2 | ||||
-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 | ||||
-rw-r--r-- | video/out/gpu/video.c | 4 | ||||
-rw-r--r-- | video/out/vo.c | 18 |
16 files changed, 75 insertions, 63 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 7713a506a6..985fd58084 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -37,6 +37,7 @@ #include "demux/stheader.h" #include "filters/f_decoder_wrapper.h" #include "filters/filter_internal.h" +#include "options/m_config.h" #include "options/options.h" struct priv { @@ -80,8 +81,9 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec, const char *decoder) { struct priv *ctx = da->priv; - struct MPOpts *mpopts = da->global->opts; - struct ad_lavc_params *opts = mpopts->ad_lavc_params; + struct MPOpts *mpopts = mp_get_config_group(ctx, da->global, GLOBAL_CONFIG); + struct ad_lavc_params *opts = + mp_get_config_group(ctx, da->global, &ad_lavc_conf); AVCodecContext *lavc_context; AVCodec *lavc_codec; diff --git a/common/global.h b/common/global.h index 8adc59e02c..f6f83cf68c 100644 --- a/common/global.h +++ b/common/global.h @@ -9,10 +9,6 @@ struct mpv_global { struct m_config_shadow *config; struct mp_client_api *client_api; char *configdir; - - // Using this is deprecated and should be avoided (missing synchronization). - // Use m_config_cache to access mpv_global.config instead. - struct MPOpts *opts; }; #endif diff --git a/common/msg.c b/common/msg.c index b8e89bec31..cb41ea4168 100644 --- a/common/msg.c +++ b/common/msg.c @@ -460,8 +460,6 @@ void mp_msg_init(struct mpv_global *global) struct mp_log *log = mp_log_new(root, &dummy, ""); global->log = log; - - mp_msg_update_msglevels(global); } // If opt is different from *current_path, reopen *file and update *current_path. @@ -501,13 +499,9 @@ static void reopen_file(char *opt, char **current_path, FILE **file, talloc_free(tmp); } -void mp_msg_update_msglevels(struct mpv_global *global) +void mp_msg_update_msglevels(struct mpv_global *global, struct MPOpts *opts) { struct mp_log_root *root = global->log->root; - struct MPOpts *opts = global->opts; - - if (!opts) - return; pthread_mutex_lock(&mp_msg_lock); @@ -522,8 +516,7 @@ void mp_msg_update_msglevels(struct mpv_global *global) } m_option_type_msglevels.free(&root->msg_levels); - m_option_type_msglevels.copy(NULL, &root->msg_levels, - &global->opts->msg_levels); + m_option_type_msglevels.copy(NULL, &root->msg_levels, &opts->msg_levels); atomic_fetch_add(&root->reload_counter, 1); pthread_mutex_unlock(&mp_msg_lock); diff --git a/common/msg_control.h b/common/msg_control.h index 4b67190155..1e41191f6f 100644 --- a/common/msg_control.h +++ b/common/msg_control.h @@ -4,9 +4,10 @@ #include <stdbool.h> struct mpv_global; +struct MPOpts; void mp_msg_init(struct mpv_global *global); void mp_msg_uninit(struct mpv_global *global); -void mp_msg_update_msglevels(struct mpv_global *global); +void mp_msg_update_msglevels(struct mpv_global *global, struct MPOpts *opts); void mp_msg_force_stderr(struct mpv_global *global, bool force_stderr); bool mp_msg_has_status_line(struct mpv_global *global); bool mp_msg_has_log_file(struct mpv_global *global); diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index 60b0453dff..0faaa72bd9 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -27,7 +27,7 @@ #include "config.h" #include "options/options.h" #include "common/msg.h" - +#include "options/m_config.h" #include "osdep/timer.h" #include "demux/demux.h" @@ -50,7 +50,7 @@ struct priv { struct mp_filter *f; struct mp_log *log; - struct MPOpts *opts; + struct m_config_cache *opt_cache; struct sh_stream *header; struct mp_codec_params *codec; @@ -162,7 +162,8 @@ struct mp_decoder_list *audio_decoder_list(void) bool mp_decoder_wrapper_reinit(struct mp_decoder_wrapper *d) { struct priv *p = d->f->priv; - struct MPOpts *opts = p->opts; + struct MPOpts *opts = p->opt_cache->opts; + m_config_cache_update(p->opt_cache); if (p->decoder) talloc_free(p->decoder->f); @@ -236,9 +237,10 @@ static bool is_valid_peak(float sig_peak) static void fix_image_params(struct priv *p, struct mp_image_params *params) { - struct MPOpts *opts = p->opts; struct mp_image_params m = *params; struct mp_codec_params *c = p->codec; + struct MPOpts *opts = p->opt_cache->opts; + m_config_cache_update(p->opt_cache); MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params)); p->dec_format = *params; @@ -302,7 +304,8 @@ static void fix_image_params(struct priv *p, static void process_video_frame(struct priv *p, struct mp_image *mpi) { - struct MPOpts *opts = p->opts; + struct MPOpts *opts = p->opt_cache->opts; + m_config_cache_update(p->opt_cache); // Note: the PTS is reordered, but the DTS is not. Both should be monotonic. double pts = mpi->pts; @@ -645,13 +648,15 @@ struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent, struct priv *p = f->priv; struct mp_decoder_wrapper *w = &p->public; - p->opts = f->global->opts; + p->opt_cache = m_config_cache_alloc(p, f->global, GLOBAL_CONFIG); p->log = f->log; p->f = f; p->header = src; p->codec = p->header->codec; w->f = f; + struct MPOpts *opts = p->opt_cache->opts; + mp_filter_add_pin(f, MP_PIN_OUT, "out"); if (p->header->type == STREAM_VIDEO) { @@ -661,8 +666,8 @@ struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent, MP_VERBOSE(p, "Container reported FPS: %f\n", p->public.fps); - if (p->opts->force_fps) { - p->public.fps = p->opts->force_fps; + if (opts->force_fps) { + p->public.fps = opts->force_fps; MP_INFO(p, "FPS forced to %5.3f.\n", p->public.fps); MP_INFO(p, "Use --no-correct-pts to force FPS based timing.\n"); } diff --git a/input/input.c b/input/input.c index c8f1a64ad5..9e96da267d 100644 --- a/input/input.c +++ b/input/input.c @@ -1370,8 +1370,11 @@ void mp_input_load_config(struct input_ctx *ictx) } #if HAVE_WIN32_PIPES - if (ictx->global->opts->input_file && *ictx->global->opts->input_file) - mp_input_pipe_add(ictx, ictx->global->opts->input_file); + char *ifile; + mp_read_option_raw(ictx->global, "input-file", &m_option_type_string, &ifile); + if (ifile && ifile[0]) + mp_input_pipe_add(ictx, ifile); + talloc_free(ifile); #endif input_unlock(ictx); diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 778f2f1e46..d39623fe4f 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -36,6 +36,7 @@ #include "common/msg.h" #include "input/input.h" #include "libmpv/client.h" +#include "options/m_config.h" #include "options/options.h" #include "options/path.h" #include "player/client.h" @@ -386,7 +387,7 @@ done: struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, struct mpv_global *global) { - struct MPOpts *opts = global->opts; + struct MPOpts *opts = mp_get_config_group(NULL, global, GLOBAL_CONFIG); struct mp_ipc_ctx *arg = talloc_ptrtype(NULL, arg); *arg = (struct mp_ipc_ctx){ @@ -397,10 +398,12 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, }; char *input_file = mp_get_user_path(arg, global, opts->input_file); + talloc_free(opts); + if (input_file && *input_file) ipc_start_client_text(arg, input_file); - if (!opts->ipc_path || !*opts->ipc_path) + if (!arg->path || !arg->path[0]) goto out; if (mp_make_wakeup_pipe(arg->death_pipe) < 0) diff --git a/input/ipc-win.c b/input/ipc-win.c index 3cbdad3749..8bfbaf409b 100644 --- a/input/ipc-win.c +++ b/input/ipc-win.c @@ -29,6 +29,7 @@ #include "common/msg.h" #include "input/input.h" #include "libmpv/client.h" +#include "options/m_config.h" #include "options/options.h" #include "player/client.h" @@ -449,7 +450,7 @@ done: struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, struct mpv_global *global) { - struct MPOpts *opts = global->opts; + struct MPOpts *opts = mp_get_config_group(NULL, global, GLOBAL_CONFIG); struct mp_ipc_ctx *arg = talloc_ptrtype(NULL, arg); *arg = (struct mp_ipc_ctx){ @@ -478,12 +479,14 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, if (pthread_create(&arg->thread, NULL, ipc_thread, arg)) goto out; + talloc_free(opts); return arg; out: if (arg->death_event) CloseHandle(arg->death_event); talloc_free(arg); + talloc_free(opts); return NULL; } diff --git a/options/parse_commandline.c b/options/parse_commandline.c index 68d36c6500..d2eb01966c 100644 --- a/options/parse_commandline.c +++ b/options/parse_commandline.c @@ -281,10 +281,8 @@ err_out: * during normal options parsing. */ void m_config_preparse_command_line(m_config_t *config, struct mpv_global *global, - char **argv) + int *verbose, char **argv) { - struct MPOpts *opts = global->opts; - struct parse_state p = {config, argv}; while (split_opt_silent(&p) == 0) { if (p.is_opt) { @@ -293,7 +291,7 @@ void m_config_preparse_command_line(m_config_t *config, struct mpv_global *globa int flags = M_SETOPT_FROM_CMDLINE | M_SETOPT_PRE_PARSE_ONLY; m_config_set_option_cli(config, p.arg, p.param, flags); if (bstrcmp0(p.arg, "v") == 0) - opts->verbose++; + (*verbose)++; } } diff --git a/options/parse_commandline.h b/options/parse_commandline.h index 8c39047814..1509fc94e2 100644 --- a/options/parse_commandline.h +++ b/options/parse_commandline.h @@ -27,6 +27,6 @@ struct mpv_global; int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, struct mpv_global *global, char **argv); void m_config_preparse_command_line(m_config_t *config, struct mpv_global *global, - char **argv); + int *verbose, char **argv); #endif /* MPLAYER_PARSER_MPCMD_H */ 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); diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 3fb460469d..46d9026742 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -3854,7 +3854,9 @@ static void reinit_from_options(struct gl_video *p) gl_video_setup_hooks(p); reinit_osd(p); - if (p->opts.interpolation && !p->global->opts->video_sync && !p->dsi_warned) { + int vs; + mp_read_option_raw(p->global, "video-sync", &m_option_type_choice, &vs); + if (p->opts.interpolation && !vs && !p->dsi_warned) { MP_WARN(p, "Interpolation now requires enabling display-sync mode.\n" "E.g.: --video-sync=display-resample\n"); p->dsi_warned = true; diff --git a/video/out/vo.c b/video/out/vo.c index 9ecfd76a1f..aa3e1b5a6a 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -332,7 +332,9 @@ error: struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex) { - struct m_obj_settings *vo_list = global->opts->vo->video_driver_list; + struct mp_vo_opts *opts = mp_get_config_group(NULL, global, &vo_sub_opts); + struct m_obj_settings *vo_list = opts->video_driver_list; + struct vo *vo = NULL; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0].name) { for (int n = 0; vo_list[n].name; n++) { @@ -340,11 +342,11 @@ struct vo *init_best_video_out(struct mpv_global *global, struct vo_extra *ex) if (strlen(vo_list[n].name) == 0) goto autoprobe; bool p = !!vo_list[n + 1].name; - struct vo *vo = vo_create(p, global, ex, vo_list[n].name); + vo = vo_create(p, global, ex, vo_list[n].name); if (vo) - return vo; + goto done; } - return NULL; + goto done; } autoprobe: // now try the rest... @@ -352,11 +354,13 @@ autoprobe: const struct vo_driver *driver = video_out_drivers[i]; if (driver == &video_out_null) break; - struct vo *vo = vo_create(true, global, ex, (char *)driver->name); + vo = vo_create(true, global, ex, (char *)driver->name); if (vo) - return vo; + goto done; } - return NULL; +done: + talloc_free(opts); + return vo; } static void terminate_vo(void *p) |