diff options
Diffstat (limited to 'player/scripting.c')
-rw-r--r-- | player/scripting.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/player/scripting.c b/player/scripting.c index b98588d948..bcb5ea65ef 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -100,13 +100,6 @@ static void *script_thread(void *p) return NULL; } -static void wait_loaded(struct MPContext *mpctx) -{ - while (!mp_clients_all_initialized(mpctx)) - mp_idle(mpctx); - mp_wakeup_core(mpctx); // avoid lost wakeups during waiting -} - static int mp_load_script(struct MPContext *mpctx, const char *fname) { char *ext = mp_splitext(fname, NULL); @@ -150,9 +143,6 @@ static int mp_load_script(struct MPContext *mpctx, const char *fname) return -1; } - wait_loaded(mpctx); - MP_DBG(mpctx, "Done loading %s.\n", fname); - return 0; } @@ -203,16 +193,11 @@ static void load_builtin_script(struct MPContext *mpctx, bool enable, if (enable) { mp_load_script(mpctx, fname); } else { - // Try to unload it by sending a shutdown event. Wait until it has - // terminated, or re-enabling the script could be racy (because it'd - // recognize a still-terminating script as "loaded"). - while (mp_client_exists(mpctx, name)) { - if (mp_client_send_event(mpctx, name, 0, MPV_EVENT_SHUTDOWN, - NULL) < 0) - break; - mp_idle(mpctx); - } - mp_wakeup_core(mpctx); // avoid lost wakeups during waiting + // Try to unload it by sending a shutdown event. This can be + // unreliable, because user scripts could have clashing names, or + // disabling and then quickly re-enabling a builtin script might + // detect the still-terminating script as loaded. + mp_client_send_event(mpctx, name, 0, MPV_EVENT_SHUTDOWN, NULL); } } talloc_free(tmp); |