summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-04 18:25:40 +0100
committerwm4 <wm4@nowhere>2015-02-04 23:04:01 +0100
commite163284b6802fe6375536f48cea281062294eaa2 (patch)
treeb5eceebaaed9e6498a77a8e63ac738c239a08f8b
parent5bce4664beaddbcc256d333816ad6cdddf16a83d (diff)
downloadmpv-e163284b6802fe6375536f48cea281062294eaa2.tar.bz2
mpv-e163284b6802fe6375536f48cea281062294eaa2.tar.xz
command: add on_unload hook
Fixes #1552.
-rw-r--r--DOCS/man/lua.rst4
-rw-r--r--player/loadfile.c10
2 files changed, 14 insertions, 0 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst
index 1cf6e99576..347292cd7b 100644
--- a/DOCS/man/lua.rst
+++ b/DOCS/man/lua.rst
@@ -755,3 +755,7 @@ guarantee a stable interface.
you could set per-file options with by setting the property
``file-local-options/<option name>``. The player will wait until all
hooks are run.
+
+ ``on_unload``
+ Run before closing a file, and before actually uninitializing
+ everything. It's not possible to resume playback in this state.
diff --git a/player/loadfile.c b/player/loadfile.c
index db032d422c..4f8b512e86 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -808,6 +808,14 @@ static int process_open_hooks(struct MPContext *mpctx)
return 0;
}
+static void process_unload_hooks(struct MPContext *mpctx)
+{
+ mp_hook_run(mpctx, NULL, "on_unload");
+
+ while (!mp_hook_test_completion(mpctx, "on_unload"))
+ mp_idle(mpctx);
+}
+
static void print_timeline(struct MPContext *mpctx)
{
if (mpctx->timeline) {
@@ -1212,6 +1220,8 @@ terminate_playback:
goto goto_reopen_demuxer;
}
+ process_unload_hooks(mpctx);
+
mp_nav_destroy(mpctx);
if (mpctx->stop_play == KEEP_PLAYING)