From 8e5642ff6872d94faf69c6305acdcfd788ddebba Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 18 Nov 2019 00:33:32 +0100 Subject: lua: don't pre-filter log level argument in mp.enable_messages() This will just make it not work if mpv_request_log_messages() gets extended to accept more names. Pass the argument without checking. To keep the behavior the same (for whatever reasons, probably not important), still raise an error if the libmpv API function returns an error that the argument was bad. (The check_loglevel() function is still used when the script _emits_ log messages, which is different, and for which there is no API anyway.) --- player/lua.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/player/lua.c b/player/lua.c index 757f449f7b..63b9b1f8c1 100644 --- a/player/lua.c +++ b/player/lua.c @@ -596,9 +596,11 @@ static int script_request_event(lua_State *L) static int script_enable_messages(lua_State *L) { struct script_ctx *ctx = get_ctx(L); - check_loglevel(L, 1); const char *level = luaL_checkstring(L, 1); - return check_error(L, mpv_request_log_messages(ctx->client, level)); + int r = mpv_request_log_messages(ctx->client, level); + if (r == MPV_ERROR_INVALID_PARAMETER) + luaL_error(L, "Invalid log level '%s'", level); + return check_error(L, r); } static int script_command(lua_State *L) -- cgit v1.2.3