summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-08 21:54:17 +0100
committerwm4 <wm4@nowhere>2016-03-08 22:01:57 +0100
commit876a3bafc5a0cb491ee1f1d5e928cd6e6ef530a8 (patch)
treeaf35260c02da290067e7a5b6bd1d5860cbb1ea7d /sub/osd.c
parent75a36662cb6bb0c8a2aeb3a4034d3f8dc745bbdd (diff)
downloadmpv-876a3bafc5a0cb491ee1f1d5e928cd6e6ef530a8.tar.bz2
mpv-876a3bafc5a0cb491ee1f1d5e928cd6e6ef530a8.tar.xz
osd: cleanup: make OSDTYPE_ constants private to OSD code
No need to have them everywhere. The only exception/annoyance is MAX_OSD_PARTS, which is now basically duplicated (and at runtime initialization is checked with an assert()).
Diffstat (limited to 'sub/osd.c')
-rw-r--r--sub/osd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sub/osd.c b/sub/osd.c
index c05fc5a0e3..e37b6cf106 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -109,6 +109,8 @@ static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
struct osd_state *osd_create(struct mpv_global *global)
{
+ assert(MAX_OSD_PARTS >= OSDTYPE_COUNT);
+
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
*osd = (struct osd_state) {
.opts = global->opts,
@@ -151,24 +153,25 @@ void osd_changed_unlocked(struct osd_state *osd, int obj)
osd->want_redraw = true;
}
-void osd_set_text(struct osd_state *osd, int obj, const char *text)
+void osd_set_text(struct osd_state *osd, const char *text)
{
pthread_mutex_lock(&osd->lock);
- struct osd_object *osd_obj = osd->objs[obj];
+ struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
if (!text)
text = "";
if (strcmp(osd_obj->text, text) != 0) {
talloc_free(osd_obj->text);
osd_obj->text = talloc_strdup(osd_obj, text);
- osd_changed_unlocked(osd, obj);
+ osd_changed_unlocked(osd, osd_obj->type);
}
pthread_mutex_unlock(&osd->lock);
}
-void osd_set_sub(struct osd_state *osd, int obj, struct dec_sub *dec_sub)
+void osd_set_sub(struct osd_state *osd, int index, struct dec_sub *dec_sub)
{
pthread_mutex_lock(&osd->lock);
- osd->objs[obj]->sub = dec_sub;
+ if (index >= 0 && index < 2)
+ osd->objs[OSDTYPE_SUB + index]->sub = dec_sub;
pthread_mutex_unlock(&osd->lock);
}
@@ -405,10 +408,11 @@ bool osd_query_and_reset_want_redraw(struct osd_state *osd)
return r;
}
-struct mp_osd_res osd_get_vo_res(struct osd_state *osd, int obj)
+struct mp_osd_res osd_get_vo_res(struct osd_state *osd)
{
pthread_mutex_lock(&osd->lock);
- struct mp_osd_res res = osd->objs[obj]->vo_res;
+ // Any OSDTYPE is fine; but it mustn't be a subtitle one (can have lower res.)
+ struct mp_osd_res res = osd->objs[OSDTYPE_OSD]->vo_res;
pthread_mutex_unlock(&osd->lock);
return res;
}