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:
wm4
2017-01-18 17:13:26 +01:00
parent 04858c0b83
commit c54c3b6991
7 changed files with 47 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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.