summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-23 20:54:04 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-26 23:06:50 -0700
commitcdbd20581e7da8657c4b17784546f2af6c579d36 (patch)
tree8b4b7153f89efa23329cbc319d28b98d6ac89c89 /player/command.c
parentf60826c3a14ba3b49077f17e5364b7347f9b468a (diff)
downloadmpv-cdbd20581e7da8657c4b17784546f2af6c579d36.tar.bz2
mpv-cdbd20581e7da8657c4b17784546f2af6c579d36.tar.xz
player: fix hook processing consistency and code duplication issues
There was a "generic" function to run a hook and to wait for its completion, yet there were two duplicated functions doing the same anyway. Replace them with a single function. They differed in how stop_play was handled, but it was broken anyway. stop_play is set when playback is stopped due to quitting or changing the playlist entry - but we still can't stop hook processing, because that would mean asynchronously doing something else while the user hook code is still busy and might still have the expectation that running the hook stops everything else. So not waiting until the hook ends properly is against the whole hook idea. That this was done inconsistently is even worse. (Though it could be argued that when quitting the player, everything should just be stopped violently. But I still think that's up to the hook handler.) process_hooks() does not return anything, since hook processing doesn't really have a result (it's all about blocking and letting some other code synchronously do something). Just let the caller check whether loading was aborted in the meantime. Also change the potentially misleading name of mp_hook_run().
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index da5a7e39f5..70a0f824a8 100644
--- a/player/command.c
+++ b/player/command.c
@@ -219,7 +219,9 @@ static int run_next_hook_handler(struct MPContext *mpctx, char *type, int index)
return 0;
}
-void mp_hook_run(struct MPContext *mpctx, char *type)
+// Start processing script/client API hooks. This is asynchronous, and the
+// caller needs to use mp_hook_test_completion() to check whether they're done.
+void mp_hook_start(struct MPContext *mpctx, char *type)
{
while (run_next_hook_handler(mpctx, type, 0) < 0) {
// We can repeat this until all broken clients have been removed, and