From 76dc5d9aa92f5c91c728004214f7b08c3a85a5f6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 May 2018 22:19:10 +0200 Subject: command: make loadlist command async and abortable Don't allow it to freeze everything when loading a playlist from network (although you definitely shouldn't do that, but whatever). This also affects the really obscure --ordered-chapters-files option. The --playlist option on the other hand has no choice but to freeze the shit, because there's no concept of aborting the player during command line parsing. --- common/playlist.c | 5 +++-- common/playlist.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/playlist.c b/common/playlist.c index b2b297d671..5504b185bc 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -275,13 +275,14 @@ struct playlist_entry *playlist_entry_from_index(struct playlist *pl, int index) } } -struct playlist *playlist_parse_file(const char *file, struct mpv_global *global) +struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel, + struct mpv_global *global) { struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser"); mp_verbose(log, "Parsing playlist file %s...\n", file); struct demuxer_params p = {.force_format = "playlist"}; - struct demuxer *d = demux_open_url(file, &p, NULL, global); + struct demuxer *d = demux_open_url(file, &p, cancel, global); if (!d) { talloc_free(log); return NULL; diff --git a/common/playlist.h b/common/playlist.h index d35fff6df3..a37c516519 100644 --- a/common/playlist.h +++ b/common/playlist.h @@ -101,8 +101,10 @@ int playlist_entry_to_index(struct playlist *pl, struct playlist_entry *e); int playlist_entry_count(struct playlist *pl); struct playlist_entry *playlist_entry_from_index(struct playlist *pl, int index); +struct mp_cancel; struct mpv_global; -struct playlist *playlist_parse_file(const char *file, struct mpv_global *global); +struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel, + struct mpv_global *global); void playlist_entry_unref(struct playlist_entry *e); -- cgit v1.2.3 From d33e5972b38c1a8d1ed2c19095a94c70c33881c3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 19 May 2018 14:41:06 +0200 Subject: demux: get rid of free_demuxer[_and_stream]() Them being separate is just dumb. Replace them with a single demux_free() function, and free its stream by default. Not freeing the stream is only needed in 1 special case (demux_disc.c), use a special flag to not free the stream in this case. --- common/playlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/playlist.c b/common/playlist.c index 5504b185bc..7572e67780 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -297,7 +297,7 @@ struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel, "pass it to the player\ndirectly. Don't use --playlist.\n"); } } - free_demuxer_and_stream(d); + demux_free(d); if (ret) { mp_verbose(log, "Playlist successfully parsed\n"); -- cgit v1.2.3 From 3569857b7580f9037f5168a2e3888a86cc3a85a0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 May 2018 15:49:19 +0200 Subject: path: don't access global option struct The path functions need to access the option that forces non-default config directories. Just add it as a field to mpv_global - it seems justified. The accessed options were always enforced as immutable after init, so there's not much of a change. --- common/global.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/global.h b/common/global.h index 879ca72386..8adc59e02c 100644 --- a/common/global.h +++ b/common/global.h @@ -8,6 +8,7 @@ struct mpv_global { struct mp_log *log; 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. -- cgit v1.2.3 From f8ab59eacdde31af39f4defeb964adf4de140a50 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 May 2018 16:25:52 +0200 Subject: player: get rid of mpv_global.opts This was always a legacy thing. Remove it by applying an orgy of mp_get_config_group() calls, and sometimes m_config_cache_alloc() or mp_read_option_raw(). win32 changes untested. --- common/global.h | 4 ---- common/msg.c | 11 ++--------- common/msg_control.h | 3 ++- 3 files changed, 4 insertions(+), 14 deletions(-) (limited to 'common') 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 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); -- cgit v1.2.3