mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player: restructure cancel callback
As preparation for file prefetching, we basically have to get rid of using mpctx->playback_abort for the main demuxer (i.e. the thing that can be prefetched). It can't be changed on a running demuxer, and always using the same cancel handle would either mean aborting playback would also abort prefetching, or that playback can't be aborted anymore. Make this more flexible with some refactoring. Thi is a quite shitty solution if you ask me, but YOLO.
This commit is contained in:
@@ -144,7 +144,8 @@ struct input_ctx {
|
||||
|
||||
struct cmd_queue cmd_queue;
|
||||
|
||||
struct mp_cancel *cancel;
|
||||
void (*cancel)(void *cancel_ctx);
|
||||
void *cancel_ctx;
|
||||
|
||||
void (*wakeup_cb)(void *ctx);
|
||||
void *wakeup_ctx;
|
||||
@@ -809,7 +810,7 @@ int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd)
|
||||
input_lock(ictx);
|
||||
if (cmd) {
|
||||
if (ictx->cancel && test_abort_cmd(ictx, cmd))
|
||||
mp_cancel_trigger(ictx->cancel);
|
||||
ictx->cancel(ictx->cancel_ctx);
|
||||
queue_add_tail(&ictx->cmd_queue, cmd);
|
||||
mp_input_wakeup(ictx);
|
||||
}
|
||||
@@ -1335,10 +1336,11 @@ void mp_input_uninit(struct input_ctx *ictx)
|
||||
talloc_free(ictx);
|
||||
}
|
||||
|
||||
void mp_input_set_cancel(struct input_ctx *ictx, struct mp_cancel *cancel)
|
||||
void mp_input_set_cancel(struct input_ctx *ictx, void (*cb)(void *c), void *c)
|
||||
{
|
||||
input_lock(ictx);
|
||||
ictx->cancel = cancel;
|
||||
ictx->cancel = cb;
|
||||
ictx->cancel_ctx = c;
|
||||
input_unlock(ictx);
|
||||
}
|
||||
|
||||
|
||||
@@ -242,8 +242,7 @@ void mp_input_wakeup(struct input_ctx *ictx);
|
||||
|
||||
// Used to asynchronously abort playback. Needed because the core still can
|
||||
// block on network in some situations.
|
||||
struct mp_cancel;
|
||||
void mp_input_set_cancel(struct input_ctx *ictx, struct mp_cancel *cancel);
|
||||
void mp_input_set_cancel(struct input_ctx *ictx, void (*cb)(void *c), void *c);
|
||||
|
||||
// If this returns true, use Right Alt key as Alt Gr to produce special
|
||||
// characters. If false, count Right Alt as the modifier Alt key.
|
||||
|
||||
Reference in New Issue
Block a user