summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorharklu <harklu@wat>2011-08-08 10:07:17 +0200
committerUoti Urpala <uau@mplayer2.org>2011-08-09 03:28:58 +0300
commitd4b8d1486a69ee5bbd96a2758f56c1bbc6242bfb (patch)
tree943c14a454c9961f7bf7f9fbcdc1ac3da32e4917 /sub
parentfada084499a33a4a1d7ef79f3ac72364a55e0c17 (diff)
downloadmpv-d4b8d1486a69ee5bbd96a2758f56c1bbc6242bfb.tar.bz2
mpv-d4b8d1486a69ee5bbd96a2758f56c1bbc6242bfb.tar.xz
core: allocate OSD text buffers dynamically
The OSD text buffers (mp_osd_msg_t.text and osd_state.text) used to be static arrays, with the buffer sizes spread all over the code as magic constants. Make the buffers dynamically allocated and remove the arbitrary length limits.
Diffstat (limited to 'sub')
-rw-r--r--sub/sub.c9
-rw-r--r--sub/sub.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/sub/sub.c b/sub/sub.c
index 880793373c..efe648948c 100644
--- a/sub/sub.c
+++ b/sub/sub.c
@@ -1239,9 +1239,18 @@ struct osd_state *osd_create(void)
#ifdef CONFIG_FREETYPE
force_load_font = 1;
#endif
+ osd_set_text(osd, NULL);
return osd;
}
+void osd_set_text(struct osd_state *osd, const char *text) {
+ talloc_free(osd->osd_text);
+ //osd->text must never be NULL
+ if (!text)
+ text = "";
+ osd->osd_text = talloc_strdup(osd, text);
+}
+
int vo_osd_changed_flag=0;
void osd_remove_text(struct osd_state *osd, int dxs, int dys,
diff --git a/sub/sub.h b/sub/sub.h
index 30a7919aa1..e7ded2556a 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -72,7 +72,7 @@ struct osd_state {
struct ass_library *ass_library;
// flag to signal reinitialization due to ass-related option changes
bool ass_force_reload;
- unsigned char osd_text[128];
+ char *osd_text;
struct font_desc *sub_font;
struct ass_track *ass_track;
bool ass_track_changed;
@@ -148,6 +148,7 @@ void osd_remove_text(struct osd_state *osd, int dxs, int dys,
void (*remove)(int x0, int y0, int w, int h));
struct osd_state *osd_create(void);
+void osd_set_text(struct osd_state *osd, const char *text);
int osd_update(struct osd_state *osd, int dxs, int dys);
int vo_osd_changed(int new_value);
int vo_osd_check_range_update(int,int,int,int);