diff options
author | wm4 <wm4@nowhere> | 2016-03-08 21:42:08 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-03-08 22:00:02 +0100 |
commit | 75a36662cb6bb0c8a2aeb3a4034d3f8dc745bbdd (patch) | |
tree | eeb8967caa71b555dcfa43ec932a90fcd9c52ebe /player | |
parent | ed254f29a93474defd932e52d6995628e01d82aa (diff) | |
download | mpv-75a36662cb6bb0c8a2aeb3a4034d3f8dc745bbdd.tar.bz2 mpv-75a36662cb6bb0c8a2aeb3a4034d3f8dc745bbdd.tar.xz |
osd, lua: manage multiple ASS overlays set with set_osd_ass() calls
Until now, there was only 1 global ASS overlay that could be set by all
scripts. This was often perceived as bug when multiple scripts tried to
set their own ASS overlay.
This was kind of hard to solve because the script could set its own ASS
PlayResX/Y, which makes it impossible to share a single ASS_Renderer for
multiple scripts. The OSC unfortunately makes use of this feature (and
unfortunately can't be fixed because it's a POS), so we're stuck with
this complication.
Implement the worst-case solution and fix this by creating separate ASS
track and renderer objects for each script that wants to set an ASS
overlay.
The z-order is decided by the order the scripts set their text first.
This is essentially random, unless you do it at script init, and you
pass scripts in a specific order. Script initialization is currently
serialized (as a feature), so the first loaded script gets lowest
Z-order.
The Lua script API interestingly remains the same. (And also will remain
undocumented, unsupported, and potentially volatile.)
Diffstat (limited to 'player')
-rw-r--r-- | player/lua.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/player/lua.c b/player/lua.c index 04c7dbb977..680577554c 100644 --- a/player/lua.c +++ b/player/lua.c @@ -391,6 +391,7 @@ static int load_lua(struct mpv_handle *client, const char *fname) r = 0; error_out: + osd_set_external(ctx->mpctx->osd, client, 0, 0, NULL); // remove overlay mp_resume_all(client); if (ctx->state) lua_close(ctx->state); @@ -963,14 +964,14 @@ static int script_command_native(lua_State *L) static int script_set_osd_ass(lua_State *L) { - struct MPContext *mpctx = get_mpctx(L); + struct script_ctx *ctx = get_ctx(L); int res_x = luaL_checkinteger(L, 1); int res_y = luaL_checkinteger(L, 2); const char *text = luaL_checkstring(L, 3); if (!text[0]) text = " "; // force external OSD initialization - osd_set_external(mpctx->osd, res_x, res_y, (char *)text); - mp_input_wakeup(mpctx->input); + osd_set_external(ctx->mpctx->osd, ctx->client, res_x, res_y, (char *)text); + mp_input_wakeup(ctx->mpctx->input); return 0; } |