mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
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.)
This commit is contained in:
19
sub/osd.c
19
sub/osd.c
@@ -145,7 +145,7 @@ void osd_free(struct osd_state *osd)
|
||||
talloc_free(osd);
|
||||
}
|
||||
|
||||
static void osd_changed_unlocked(struct osd_state *osd, int obj)
|
||||
void osd_changed_unlocked(struct osd_state *osd, int obj)
|
||||
{
|
||||
osd->objs[obj]->force_redraw = true;
|
||||
osd->want_redraw = true;
|
||||
@@ -201,23 +201,6 @@ void osd_set_progbar(struct osd_state *osd, struct osd_progbar_state *s)
|
||||
pthread_mutex_unlock(&osd->lock);
|
||||
}
|
||||
|
||||
void osd_set_external(struct osd_state *osd, int res_x, int res_y, char *text)
|
||||
{
|
||||
pthread_mutex_lock(&osd->lock);
|
||||
struct osd_object *osd_obj = osd->objs[OSDTYPE_EXTERNAL];
|
||||
if (strcmp(osd_obj->text, text) != 0 ||
|
||||
osd_obj->external_res_x != res_x ||
|
||||
osd_obj->external_res_y != res_y)
|
||||
{
|
||||
talloc_free(osd_obj->text);
|
||||
osd_obj->text = talloc_strdup(osd_obj, text);
|
||||
osd_obj->external_res_x = res_x;
|
||||
osd_obj->external_res_y = res_y;
|
||||
osd_changed_unlocked(osd, osd_obj->type);
|
||||
}
|
||||
pthread_mutex_unlock(&osd->lock);
|
||||
}
|
||||
|
||||
void osd_set_external2(struct osd_state *osd, struct sub_bitmaps *imgs)
|
||||
{
|
||||
pthread_mutex_lock(&osd->lock);
|
||||
|
||||
Reference in New Issue
Block a user