From 12d1404b04e90f5357882e5c1048d92305248cb9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 May 2018 21:38:17 +0200 Subject: player: make various commands for managing external tracks abortable Until now, they could be aborted only by ending playback, and calling mpv_abort_async_command didn't do anything. This requires furthering the mess how playback abort is done. The main reason why mp_cancel exists at all is to avoid that a "frozen" demuxer (blocked on network I/O or whatever) cannot freeze the core. The core should always get its way. Previously, there was a single mp_cancel handle, that could be signaled, and all demuxers would unfreeze. With external files, we might want to abort loading of a certain external file, which automatically means they need a separate mp_cancel. So give every demuxer its own mp_cancel, and "slave" it to whatever parent mp_cancel handles aborting. Since the mpv demuxer API conflates creating the demuxer and reading the file headers, mp_cancel strictly need to be created before the demuxer is created (or we couldn't abort loading). Although we give every demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer), it's still rather messy to create/destroy it along with the demuxer. --- player/core.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'player/core.h') diff --git a/player/core.h b/player/core.h index b0d9b2a5ea..43fc824e4f 100644 --- a/player/core.h +++ b/player/core.h @@ -441,7 +441,6 @@ typedef struct MPContext { pthread_mutex_t abort_lock; // --- The following fields are protected by abort_lock - struct mp_cancel *demuxer_cancel; // cancel handle for MPContext.demuxer struct mp_abort_entry **abort_list; int num_abort_list; bool abort_all; // during final termination @@ -513,7 +512,7 @@ void mp_abort_trigger_locked(struct MPContext *mpctx, struct mp_abort_entry *abort); void uninit_player(struct MPContext *mpctx, unsigned int mask); int mp_add_external_file(struct MPContext *mpctx, char *filename, - enum stream_type filter); + enum stream_type filter, struct mp_cancel *cancel); #define FLAG_MARK_SELECTION 1 void mp_switch_track(struct MPContext *mpctx, enum stream_type type, struct track *track, int flags); @@ -532,7 +531,7 @@ void update_demuxer_properties(struct MPContext *mpctx); void print_track_list(struct MPContext *mpctx, const char *msg); void reselect_demux_stream(struct MPContext *mpctx, struct track *track); void prepare_playlist(struct MPContext *mpctx, struct playlist *pl); -void autoload_external_files(struct MPContext *mpctx); +void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel); struct track *select_default_track(struct MPContext *mpctx, int order, enum stream_type type); void prefetch_next(struct MPContext *mpctx); -- cgit v1.2.3