diff options
author | wm4 <wm4@nowhere> | 2017-01-18 17:13:26 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-18 17:52:05 +0100 |
commit | c54c3b6991ac0273e6b7a42dc42c5103f87ff9f1 (patch) | |
tree | 1b543741e9bf171fa9a77fe90e4df9f62396284d /input | |
parent | 04858c0b83fd6c1fc60519c2034e263d2e7c3977 (diff) | |
download | mpv-c54c3b6991ac0273e6b7a42dc42c5103f87ff9f1.tar.bz2 mpv-c54c3b6991ac0273e6b7a42dc42c5103f87ff9f1.tar.xz |
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.
Diffstat (limited to 'input')
-rw-r--r-- | input/input.c | 10 | ||||
-rw-r--r-- | input/input.h | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/input/input.c b/input/input.c index 9525dbcbb1..f0f9f64e9b 100644 --- a/input/input.c +++ b/input/input.c @@ -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); } diff --git a/input/input.h b/input/input.h index 5b5edd580d..fb928e0808 100644 --- a/input/input.h +++ b/input/input.h @@ -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. |