Showing the changes to TOOLS/lua (1 of 2 files). Show all
Unified · Split
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | local utils = require("mp.utils") | 3 | local utils = require("mp.utils") |
| 4 | 4 | ||
| 5 | function join(sep, arr, count) | 5 | local function join(sep, arr, count) |
| 6 | local r = "" | 6 | local r = "" |
| 7 | if count == nil then | 7 | if count == nil then |
| 8 | count = #arr | 8 | count = #arr |
| @@ -31,19 +31,19 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 22 unmodified lines | |||
| 31 | mp.set_property("screenshot-format", "png") | 31 | mp.set_property("screenshot-format", "png") |
| 32 | mp.set_property("screenshot-png-compression", "9") | 32 | mp.set_property("screenshot-png-compression", "9") |
| 33 | 33 | ||
| 34 | timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) | 34 | local timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) |
| 35 | timer:resume() | 35 | timer:resume() |
| 36 | 36 | ||
| 37 | print("Slow screenshot command...") | 37 | print("Slow screenshot command...") |
| 38 | res = mp.command_native({"screenshot"}) | 38 | local result = mp.command_native({"screenshot"}) |
| 39 | print("done, res: " .. utils.to_string(res)) | 39 | print("done, res: " .. utils.to_string(result)) |
| 40 | 40 | ||
| 41 | print("Slow screenshot async command...") | 41 | print("Slow screenshot async command...") |
| 42 | res = mp.command_native_async({"screenshot"}, function(res) | 42 | result = mp.command_native_async({"screenshot"}, function(res) |
| 43 | print("done (async), res: " .. utils.to_string(res)) | 43 | print("done (async), res: " .. utils.to_string(res)) |
| 44 | timer:kill() | 44 | timer:kill() |
| 45 | end) | 45 | end) |
| 46 | print("done (sending), res: " .. utils.to_string(res)) | 46 | print("done (sending), res: " .. utils.to_string(result)) |
| 47 | 47 | ||
| 48 | print("Broken screenshot async command...") | 48 | print("Broken screenshot async command...") |
| 49 | mp.command_native_async({"screenshot-to-file", "/nonexistent/bogus.png"}, | 49 | mp.command_native_async({"screenshot-to-file", "/nonexistent/bogus.png"}, |
| @@ -51,7 +51,11 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 1 unmodified line | |||
| 51 | print("done err scr.: " .. join(" ", {res, val, err})) | 51 | print("done err scr.: " .. join(" ", {res, val, err})) |
| 52 | end) | 52 | end) |
| 53 | 53 | ||
| 54 | mp.command_native_async({name = "subprocess", args = {"sh", "-c", "echo hi && sleep 10s"}, capture_stdout = true}, | 54 | mp.command_native_async({ |
| 55 | name = "subprocess", | ||
| 56 | args = {"sh", "-c", "echo hi && sleep 10s"}, | ||
| 57 | capture_stdout = true | ||
| 58 | }, | ||
| 55 | function(res, val, err) | 59 | function(res, val, err) |
| 56 | print("done subprocess: " .. join(" ", {res, val, err})) | 60 | print("done subprocess: " .. join(" ", {res, val, err})) |
| 57 | end) | 61 | end) |
| @@ -105,7 +109,8 @@ mp.observe_property("vo-configured", "bool", function(_, v) · 47 unmodified lines | |||
| 105 | playback_only = false, args = {"sleep", "inf"}}) | 109 | playback_only = false, args = {"sleep", "inf"}}) |
| 106 | end) | 110 | end) |
| 107 | 111 | ||
| 108 | function freeze_test(playback_only) | 112 | local counter |
| 113 | local function freeze_test(playback_only) | ||
| 109 | -- This "freezes" the script, should be killed via timeout. | 114 | -- This "freezes" the script, should be killed via timeout. |
| 110 | counter = counter and counter + 1 or 0 | 115 | counter = counter and counter + 1 or 0 |
| 111 | print("freeze! " .. counter) | 116 | print("freeze! " .. counter) |