From b8ade7c99b830ee9870040bcfc1f2c3d3a64d172 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 16 Sep 2016 14:23:54 +0200 Subject: player, ao, vo: don't call mp_input_wakeup() directly Currently, calling mp_input_wakeup() will wake up the core thread (also called the playloop). This seems odd, but currently the core indeed calls mp_input_wait() when it has nothing more to do. It's done this way because MPlayer used input_ctx as central "mainloop". This is probably going to change. Remove direct calls to this function, and replace it with mp_wakeup_core() calls. ao and vo are changed to use opaque callbacks and not use input_ctx for this purpose. Other code already uses opaque callbacks, or has legitimate reasons to use input_ctx directly (such as sending actual user input). --- player/playloop.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'player/playloop.c') diff --git a/player/playloop.c b/player/playloop.c index 449813c777..f2f421021d 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -50,13 +50,28 @@ #include "client.h" #include "command.h" -// Wait until mp_input_wakeup(mpctx->input) is called, since the last time +// Wait until mp_wakeup_core() is called, since the last time // mp_wait_events() was called. (But see mp_process_input().) void mp_wait_events(struct MPContext *mpctx, double sleeptime) { mp_input_wait(mpctx->input, sleeptime); } +// Cause the playloop to run. This can be called from any thread. If called +// from within the playloop itself, it will be run immediately again, instead +// of going to sleep in the next mp_wait_events(). +void mp_wakeup_core(struct MPContext *mpctx) +{ + mp_input_wakeup(mpctx->input); +} + +// Opaque callback variant of mp_wakeup_core(). +void mp_wakeup_core_cb(void *ctx) +{ + struct MPContext *mpctx = ctx; + mp_wakeup_core(mpctx); +} + // Process any queued input, whether it's user input, or requests from client // API threads. This also resets the "wakeup" flag used with mp_wait_events(). void mp_process_input(struct MPContext *mpctx) @@ -816,6 +831,8 @@ int handle_force_window(struct MPContext *mpctx, bool force) .osd = mpctx->osd, .encode_lavc_ctx = mpctx->encode_lavc_ctx, .opengl_cb_context = mpctx->gl_cb_ctx, + .wakeup_cb = mp_wakeup_core_cb, + .wakeup_ctx = mpctx, }; mpctx->video_out = init_best_video_out(mpctx->global, &ex); if (!mpctx->video_out) -- cgit v1.2.3