summaryrefslogtreecommitdiffstats
path: root/player/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-17 21:55:23 +0100
committerwm4 <wm4@nowhere>2014-01-17 21:55:23 +0100
commitc47c59f2df6e3a394c0484d894136df8ebe10297 (patch)
treeac812f3a9b9f3d40697cc55c5ec3ef1bb66b273d /player/osd.c
parent7e1bc6be000c1febb996b48ae2559a241e2ab993 (diff)
downloadmpv-c47c59f2df6e3a394c0484d894136df8ebe10297.tar.bz2
mpv-c47c59f2df6e3a394c0484d894136df8ebe10297.tar.xz
player: don't use OSD message stack for term OSD subs
Showing subtitles on terminal used the OSD message stack (which uses a stack to "pile up" messages that were displayed at the same time). This had a bunch of weird and annoying consequences. This accessed a certain osd_state field, which is a minor annoyance since I want to make that struct opaque. Implement this differently.
Diffstat (limited to 'player/osd.c')
-rw-r--r--player/osd.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/player/osd.c b/player/osd.c
index 6c12f2d16d..44837f22b2 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -68,8 +68,10 @@ static char *join_lines(void *ta_ctx, char **parts, int num_parts)
static void term_osd_update(struct MPContext *mpctx)
{
int num_parts = 0;
- char *parts[2] = {0};
+ char *parts[3] = {0};
+ if (mpctx->term_osd_subs && mpctx->term_osd_subs[0])
+ parts[num_parts++] = mpctx->term_osd_subs;
if (mpctx->term_osd_text && mpctx->term_osd_text[0])
parts[num_parts++] = mpctx->term_osd_text;
if (mpctx->term_osd_status && mpctx->term_osd_status[0])
@@ -88,6 +90,17 @@ static void term_osd_update(struct MPContext *mpctx)
}
}
+static void term_osd_set_subs(struct MPContext *mpctx, const char *text)
+{
+ if (mpctx->video_out || !text)
+ text = ""; // disable
+ if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
+ return;
+ talloc_free(mpctx->term_osd_subs);
+ mpctx->term_osd_subs = talloc_strdup(mpctx, text);
+ term_osd_update(mpctx);
+}
+
static void term_osd_set_text(struct MPContext *mpctx, const char *text)
{
if (mpctx->video_out && mpctx->opts->term_osd != 1)
@@ -425,18 +438,8 @@ void set_osd_function(struct MPContext *mpctx, int osd_function)
*/
void set_osd_subtitle(struct MPContext *mpctx, const char *text)
{
- if (!text)
- text = "";
- if (strcmp(mpctx->osd->objs[OSDTYPE_SUB]->sub_text, text) != 0) {
- osd_set_sub(mpctx->osd, mpctx->osd->objs[OSDTYPE_SUB], text);
- if (!mpctx->video_out) {
- rm_osd_msg(mpctx, OSD_MSG_SUB_BASE);
- if (text && text[0])
- set_osd_msg(mpctx, OSD_MSG_SUB_BASE, 1, INT_MAX, "%s", text);
- }
- }
- if (!text[0])
- rm_osd_msg(mpctx, OSD_MSG_SUB_BASE);
+ osd_set_sub(mpctx->osd, mpctx->osd->objs[OSDTYPE_SUB], text);
+ term_osd_set_subs(mpctx, text);
}
// sym == mpctx->osd_function