summaryrefslogtreecommitdiffstats
path: root/sub/osd_state.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-18 01:19:20 +0100
committerwm4 <wm4@nowhere>2014-01-18 01:27:43 +0100
commit7f4a09bb8534dfafd83099d773adf2e33c64e267 (patch)
tree5b75791151f92e164fbd9badee47590d1164683d /sub/osd_state.h
parent92a9f11a0b4fda60c8880014be5920dcf3e95253 (diff)
downloadmpv-7f4a09bb8534dfafd83099d773adf2e33c64e267.tar.bz2
mpv-7f4a09bb8534dfafd83099d773adf2e33c64e267.tar.xz
sub: uglify OSD code path with locking
Do two things: 1. add locking to struct osd_state 2. make struct osd_state opaque While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses lots of osd_state (and osd_object) members. To make sure everything is accessed synchronously, I prefer making osd_state opaque, even if it means adding pretty dumb accessors. All of this is meant to allow running VO in their own threads. Eventually, VOs will request OSD on their own, which means osd_state will be accessed from foreign threads.
Diffstat (limited to 'sub/osd_state.h')
-rw-r--r--sub/osd_state.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/sub/osd_state.h b/sub/osd_state.h
new file mode 100644
index 0000000000..55e484e3e0
--- /dev/null
+++ b/sub/osd_state.h
@@ -0,0 +1,68 @@
+#ifndef MP_OSD_STATE_H_
+#define MP_OSD_STATE_H_
+
+#include <pthread.h>
+
+#include "osd.h"
+
+#define OSD_CONV_CACHE_MAX 4
+
+struct osd_object {
+ int type; // OSDTYPE_*
+ bool is_sub;
+
+ bool force_redraw;
+
+ // OSDTYPE_SUB/OSDTYPE_SUB2/OSDTYPE_OSD/OSDTYPE_EXTERNAL
+ char *text;
+
+ // OSDTYPE_PROGBAR
+ struct osd_progbar_state progbar_state;
+
+ // OSDTYPE_SUB/OSDTYPE_SUB2
+ struct osd_sub_state sub_state;
+
+ // OSDTYPE_EXTERNAL
+ int external_res_x, external_res_y;
+
+ // OSDTYPE_EXTERNAL2
+ struct sub_bitmaps *external2;
+
+ // OSDTYPE_NAV_HIGHLIGHT
+ void *highlight_priv;
+
+ // caches for OSD conversion (internal to render_object())
+ struct osd_conv_cache *cache[OSD_CONV_CACHE_MAX];
+ struct sub_bitmaps cached;
+
+ // VO cache state
+ int vo_bitmap_id;
+ int vo_bitmap_pos_id;
+ struct mp_osd_res vo_res;
+
+ // Internally used by osd_libass.c
+ struct sub_bitmap *parts_cache;
+ struct ass_track *osd_track;
+ struct ass_renderer *osd_render;
+ struct ass_library *osd_ass_library;
+};
+
+struct osd_state {
+ pthread_mutex_t lock;
+
+ struct osd_object *objs[MAX_OSD_PARTS];
+
+ double vo_pts;
+
+ bool render_subs_in_filter;
+
+ bool want_redraw;
+
+ struct MPOpts *opts;
+ struct mpv_global *global;
+ struct mp_log *log;
+
+ struct mp_draw_sub_cache *draw_cache;
+};
+
+#endif