summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-18 21:38:17 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:35 +0200
commit12d1404b04e90f5357882e5c1048d92305248cb9 (patch)
tree240ab8d9dfa37c63889a5608b7733fa8d5c31780 /TOOLS
parentf9713921a372aa14ea631b0c546d3fbeade32b71 (diff)
downloadmpv-12d1404b04e90f5357882e5c1048d92305248cb9.tar.bz2
mpv-12d1404b04e90f5357882e5c1048d92305248cb9.tar.xz
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling mpv_abort_async_command didn't do anything. This requires furthering the mess how playback abort is done. The main reason why mp_cancel exists at all is to avoid that a "frozen" demuxer (blocked on network I/O or whatever) cannot freeze the core. The core should always get its way. Previously, there was a single mp_cancel handle, that could be signaled, and all demuxers would unfreeze. With external files, we might want to abort loading of a certain external file, which automatically means they need a separate mp_cancel. So give every demuxer its own mp_cancel, and "slave" it to whatever parent mp_cancel handles aborting. Since the mpv demuxer API conflates creating the demuxer and reading the file headers, mp_cancel strictly need to be created before the demuxer is created (or we couldn't abort loading). Although we give every demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer), it's still rather messy to create/destroy it along with the demuxer.
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/command-test.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua
index 79c1127cbf..dd384818cc 100644
--- a/TOOLS/lua/command-test.lua
+++ b/TOOLS/lua/command-test.lua
@@ -65,6 +65,18 @@ mp.observe_property("vo-configured", "bool", function(_, v)
mp.abort_async_command(x)
end)
+ -- (assuming this "freezes")
+ local y = mp.command_native_async({name = "sub-add", url = "-"},
+ function(res, val, err)
+ print("done sub-add stdin: " .. join(" ", {res, val, err}))
+ end)
+ mp.add_timeout(20, function()
+ print("aborting sub-add stdin after timeout")
+ mp.abort_async_command(y)
+ end)
+
+
+
-- This should get killed on script exit.
mp.command_native_async({name = "subprocess", playback_only = false,
args = {"sleep", "inf"}}, function()end)