mirror of https://github.com/mpv-player/mpv
lua: some minor API changes
This commit is contained in:
parent
33c6cbef3a
commit
212d4e6061
17
player/lua.c
17
player/lua.c
|
@ -354,18 +354,20 @@ static int script_suspend(lua_State *L)
|
||||||
static int script_resume(lua_State *L)
|
static int script_resume(lua_State *L)
|
||||||
{
|
{
|
||||||
struct script_ctx *ctx = get_ctx(L);
|
struct script_ctx *ctx = get_ctx(L);
|
||||||
static const char *modes[] = {"normal", "all", NULL};
|
|
||||||
if (luaL_checkoption(L, 1, "normal", modes) == 1) {
|
|
||||||
if (ctx->suspended)
|
|
||||||
mpv_resume(ctx->client);
|
|
||||||
ctx->suspended = 0;
|
|
||||||
} else {
|
|
||||||
if (ctx->suspended < 1)
|
if (ctx->suspended < 1)
|
||||||
luaL_error(L, "trying to resume, but core is not suspended");
|
luaL_error(L, "trying to resume, but core is not suspended");
|
||||||
ctx->suspended--;
|
ctx->suspended--;
|
||||||
if (!ctx->suspended)
|
if (!ctx->suspended)
|
||||||
mpv_resume(ctx->client);
|
mpv_resume(ctx->client);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int script_resume_all(lua_State *L)
|
||||||
|
{
|
||||||
|
struct script_ctx *ctx = get_ctx(L);
|
||||||
|
if (ctx->suspended)
|
||||||
|
mpv_resume(ctx->client);
|
||||||
|
ctx->suspended = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,6 +740,7 @@ static struct fn_entry fn_list[] = {
|
||||||
FN_ENTRY(log),
|
FN_ENTRY(log),
|
||||||
FN_ENTRY(suspend),
|
FN_ENTRY(suspend),
|
||||||
FN_ENTRY(resume),
|
FN_ENTRY(resume),
|
||||||
|
FN_ENTRY(resume_all),
|
||||||
FN_ENTRY(wait_event),
|
FN_ENTRY(wait_event),
|
||||||
FN_ENTRY(request_event),
|
FN_ENTRY(request_event),
|
||||||
FN_ENTRY(find_config_file),
|
FN_ENTRY(find_config_file),
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
function mp.get_script_name()
|
||||||
|
return mp.script_name
|
||||||
|
end
|
||||||
|
|
||||||
local callbacks = {}
|
local callbacks = {}
|
||||||
-- each script has its own section, so that they don't conflict
|
-- each script has its own section, so that they don't conflict
|
||||||
|
@ -133,7 +136,7 @@ local event_handlers = {}
|
||||||
|
|
||||||
function mp.register_event(name, cb)
|
function mp.register_event(name, cb)
|
||||||
event_handlers[name] = cb
|
event_handlers[name] = cb
|
||||||
mp.request_event(name, true)
|
return mp.request_event(name, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- default handlers
|
-- default handlers
|
||||||
|
@ -169,7 +172,7 @@ _G.mp_event_loop = function()
|
||||||
-- Resume playloop - important especially if an error happened while
|
-- Resume playloop - important especially if an error happened while
|
||||||
-- suspended, and the error was handled, but no resume was done.
|
-- suspended, and the error was handled, but no resume was done.
|
||||||
if wait > 0 then
|
if wait > 0 then
|
||||||
mp.resume("all")
|
mp.resume_all()
|
||||||
end
|
end
|
||||||
local e = mp.wait_event(wait)
|
local e = mp.wait_event(wait)
|
||||||
-- Empty the event queue while suspended; otherwise, each
|
-- Empty the event queue while suspended; otherwise, each
|
||||||
|
|
Loading…
Reference in New Issue