summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mencoder.c6
-rw-r--r--mp_osd.h1
-rw-r--r--mpcommon.c9
-rw-r--r--mpcommon.h1
-rw-r--r--mplayer.c23
5 files changed, 34 insertions, 6 deletions
diff --git a/mencoder.c b/mencoder.c
index 8d43106fde..b17e2be6a8 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -218,6 +218,12 @@ void mplayer_put_key(int code)
char *current_module;
#include "mpcommon.h"
+// Needed by mpcommon.c
+void set_osd_subtitle(subtitle *subs) {
+ vo_sub = subs;
+ vo_osd_changed(OSDTYPE_SUBTITLE);
+}
+
//char *out_audio_codec=NULL; // override audio codec
//char *out_video_codec=NULL; // override video codec
diff --git a/mp_osd.h b/mp_osd.h
index f3b2a69561..adaba8adab 100644
--- a/mp_osd.h
+++ b/mp_osd.h
@@ -11,6 +11,7 @@
#define OSD_MSG_RADIO_CHANNEL 7
/// Base id for messages generated from the commmand to property bridge.
#define OSD_MSG_PROPERTY 0x100
+#define OSD_MSG_SUB_BASE 0x1000
#define MAX_OSD_LEVEL 3
#define MAX_TERM_OSD_LEVEL 1
diff --git a/mpcommon.c b/mpcommon.c
index e28614390d..162dbbf26e 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -75,8 +75,7 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
if (reset) {
sub_clear_text(&subs, MP_NOPTS_VALUE);
if (vo_sub) {
- vo_sub = NULL;
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ set_osd_subtitle(NULL);
}
if (vo_spudec) {
spudec_reset(vo_spudec);
@@ -145,7 +144,6 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
} else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) {
double curpts = refpts + sub_delay;
double endpts;
- vo_sub = &subs;
while (d_dvdsub->first) {
double subpts = ds_get_next_pts(d_dvdsub);
if (subpts > curpts)
@@ -167,7 +165,6 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
(long long)(subpts*1000 + 0.5),
(long long)((endpts-subpts)*1000 + 0.5));
} else { // plaintext subs with libass
- vo_sub = NULL;
if (subpts != MP_NOPTS_VALUE) {
if (endpts == MP_NOPTS_VALUE) endpts = subpts + 3;
sub_clear_text(&subs, MP_NOPTS_VALUE);
@@ -195,11 +192,11 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd
packet = p;
}
sub_add_text(&subs, packet, len, endpts);
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ set_osd_subtitle(&subs);
}
}
if (sub_clear_text(&subs, curpts))
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ set_osd_subtitle(&subs);
}
current_module=NULL;
}
diff --git a/mpcommon.h b/mpcommon.h
index 65e2c52edc..486faa7012 100644
--- a/mpcommon.h
+++ b/mpcommon.h
@@ -13,6 +13,7 @@ void print_version(const char* name);
void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset);
void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset);
int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
+void set_osd_subtitle(subtitle *subs);
extern int disable_system_conf;
extern int disable_user_conf;
diff --git a/mplayer.c b/mplayer.c
index 7064223e09..aa59ab7088 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1507,6 +1507,26 @@ void set_osd_bar(int type,const char* name,double min,double max,double val) {
name,ROUND(100*(val-min)/(max-min)));
}
+/**
+ * \brief Display text subtitles on the OSD
+ */
+void set_osd_subtitle(subtitle *subs) {
+ int i;
+ vo_sub = subs;
+ vo_osd_changed(OSDTYPE_SUBTITLE);
+ if (!mpctx->sh_video) {
+ // reverse order, since newest set_osd_msg is displayed first
+ for (i = SUB_MAX_TEXT - 1; i >= 0; i--) {
+ if (!subs || i >= subs->lines || !subs->text[i])
+ rm_osd_msg(OSD_MSG_SUB_BASE + i);
+ else {
+ // HACK: currently display time for each sub line except the last is set to 2 seconds.
+ int display_time = i == subs->lines - 1 ? 180000 : 2000;
+ set_osd_msg(OSD_MSG_SUB_BASE + i, 1, display_time, "%s", subs->text[i]);
+ }
+ }
+ }
+}
/**
* \brief Update the OSD message line.
@@ -2492,6 +2512,8 @@ static int seek(MPContext *mpctx, double amount, int style)
mpctx->audio_out->reset(); // stop audio, throwing away buffered data
mpctx->sh_audio->a_buffer_len = 0;
mpctx->sh_audio->a_out_buffer_len = 0;
+ if (!mpctx->sh_video)
+ update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 1);
}
if (vo_vobsub && mpctx->sh_video) {
@@ -3704,6 +3726,7 @@ if(!mpctx->sh_video) {
if(end_at.type == END_AT_TIME && end_at.pos < a_pos)
mpctx->eof = PT_NEXT_ENTRY;
+ update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 0);
update_osd_msg();
} else {