diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/loadfile.c | 7 | ||||
-rw-r--r-- | player/main.c | 10 |
3 files changed, 9 insertions, 9 deletions
diff --git a/player/core.h b/player/core.h index 5c40e48674..9d9fefee21 100644 --- a/player/core.h +++ b/player/core.h @@ -169,6 +169,7 @@ typedef struct MPContext { struct input_ctx *input; struct mp_client_api *clients; struct mp_dispatch_queue *dispatch; + struct mp_cancel *playback_abort; struct mp_log *statusline; struct osd_state *osd; diff --git a/player/loadfile.c b/player/loadfile.c index 4f4db2a376..b8efb92ca5 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1005,6 +1005,8 @@ static void play_current_file(struct MPContext *mpctx) mp_notify(mpctx, MPV_EVENT_START_FILE, NULL); + mp_cancel_reset(mpctx->playback_abort); + mpctx->stop_play = 0; mpctx->filename = NULL; mpctx->shown_aframes = 0; @@ -1085,7 +1087,8 @@ static void play_current_file(struct MPContext *mpctx) int stream_flags = STREAM_READ; if (!opts->load_unsafe_playlists) stream_flags |= mpctx->playing->stream_flags; - mpctx->stream = stream_create(stream_filename, stream_flags, mpctx->global); + mpctx->stream = stream_create(stream_filename, stream_flags, + mpctx->playback_abort, mpctx->global); if (!mpctx->stream) { // error... mp_process_input(mpctx); goto terminate_playback; @@ -1307,6 +1310,8 @@ terminate_playback: if (mpctx->step_frames) opts->pause = 1; + mp_cancel_trigger(mpctx->playback_abort); + MP_INFO(mpctx, "\n"); // time to uninit all, except global stuff: diff --git a/player/main.c b/player/main.c index 6f9a0fcca8..93f974c107 100644 --- a/player/main.c +++ b/player/main.c @@ -308,6 +308,7 @@ struct MPContext *mp_create(void) .osd_progbar = { .type = -1 }, .playlist = talloc_struct(mpctx, struct playlist, {0}), .dispatch = mp_dispatch_create(mpctx), + .playback_abort = mp_cancel_new(mpctx), }; mpctx->global = talloc_zero(mpctx, struct mpv_global); @@ -341,12 +342,6 @@ struct MPContext *mp_create(void) return mpctx; } -static int check_stream_interrupt(void *ctx) -{ - struct MPContext *mpctx = ctx; - return mp_input_check_interrupt(mpctx->input); -} - static void wakeup_playloop(void *ctx) { struct MPContext *mpctx = ctx; @@ -383,8 +378,7 @@ int mp_initialize(struct MPContext *mpctx) } mpctx->input = mp_input_init(mpctx->global); - mpctx->global->stream_interrupt_cb = check_stream_interrupt; - mpctx->global->stream_interrupt_cb_ctx = mpctx; + mp_input_set_cancel(mpctx->input, mpctx->playback_abort); mp_dispatch_set_wakeup_fn(mpctx->dispatch, wakeup_playloop, mpctx); |