summaryrefslogtreecommitdiffstats
path: root/player/core.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-12 18:46:37 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commite4fb23ed7de874bb2d05824d7edb84cfd1b21101 (patch)
treeff56d6949cdead5795607c86882ce44aca0b7da7 /player/core.h
parentce1f5e78c2b10e24c78d7ee65d7196093709b8ce (diff)
downloadmpv-e4fb23ed7de874bb2d05824d7edb84cfd1b21101.tar.bz2
mpv-e4fb23ed7de874bb2d05824d7edb84cfd1b21101.tar.xz
command: add a way to abort asynchronous commands
Many asynchronous commands are potentially long running operations, such as loading something from network or running a foreign process. Obviously it shouldn't just be possible for them to freeze the player if they don't terminate as expected. Also, there will be situations where you want to explicitly stop some of those operations explicitly. So add an infrastructure for this. Commands have to support this explicitly. The next commit uses this to actually add support to a command.
Diffstat (limited to 'player/core.h')
-rw-r--r--player/core.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/player/core.h b/player/core.h
index 0434c5cb64..a42b1252b8 100644
--- a/player/core.h
+++ b/player/core.h
@@ -442,6 +442,8 @@ typedef struct MPContext {
// --- 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;
// --- Owned by MPContext
pthread_t open_thread;
@@ -459,6 +461,20 @@ typedef struct MPContext {
int open_res_error;
} MPContext;
+// Contains information about an asynchronous work item, how it can be aborted,
+// and when. All fields are protected by MPContext.abort_lock.
+struct mp_abort_entry {
+ // General conditions.
+ bool coupled_to_playback; // trigger when playback is terminated
+ // Actual trigger to abort the work.
+ struct mp_cancel *cancel;
+ // For client API.
+ struct mpv_handle *client; // non-NULL if done by a client API user
+ int client_work_type; // client API type, e.h. MPV_EVENT_COMMAND_REPLY
+ uint64_t client_work_id; // client API user reply_userdata value
+ // (only valid if client_work_type set)
+};
+
// audio.c
void reset_audio_state(struct MPContext *mpctx);
void reinit_audio_chain(struct MPContext *mpctx);
@@ -488,6 +504,12 @@ struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
// loadfile.c
void mp_abort_playback_async(struct MPContext *mpctx);
+void mp_abort_add(struct MPContext *mpctx, struct mp_abort_entry *abort);
+void mp_abort_remove(struct MPContext *mpctx, struct mp_abort_entry *abort);
+void mp_abort_recheck_locked(struct MPContext *mpctx,
+ struct mp_abort_entry *abort);
+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);