summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-10-06 04:28:59 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-10-06 04:48:00 +0300
commit7fd3eb0f74e7986e07556077ed654bad7869add8 (patch)
tree8d293145c0ef2bc31ca63f79dccb4e3b57294c82 /mplayer.c
parentef438b3a6b5bc714d521dd46d3ccb798ecd31eed (diff)
parentcbbc886820e981f488660708678f528e1d243121 (diff)
downloadmpv-7fd3eb0f74e7986e07556077ed654bad7869add8.tar.bz2
mpv-7fd3eb0f74e7986e07556077ed654bad7869add8.tar.xz
Merge svn changes up to r29752
As part of merging subtitle-in-terminal changes make update_subtitles() only clear existing subtitles if called with the reset argument, and not try to set new ones. Later calls should set the needed new subtitles, and this change avoids some problems with trying to set subtitles when mp_property_sub() in command.c gets called from initialization code before full initialization.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/mplayer.c b/mplayer.c
index 1677b601ef..c306c73b4f 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1493,6 +1493,27 @@ void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,d
name, ROUND(100*(val-min)/(max-min)));
}
+/**
+ * \brief Display text subtitles on the OSD
+ */
+void set_osd_subtitle(struct MPContext *mpctx, 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.
@@ -2251,7 +2272,8 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx,
#endif
if (decoded_frame) {
// These updates are done here for vf_expand OSD/subtitles
- update_subtitles(sh_video, mpctx->d_sub, mpctx->video_offset, 0);
+ update_subtitles(mpctx, &mpctx->opts, sh_video, sh_video->pts,
+ mpctx->video_offset, mpctx->d_sub, 0);
update_teletext(sh_video, mpctx->demuxer, 0);
update_osd_msg(mpctx);
current_module = "filter video";
@@ -2304,7 +2326,8 @@ static double update_video(struct MPContext *mpctx, int *blit_frame)
framedrop_type, pts);
if (decoded_frame) {
// These updates are done here for vf_expand OSD/subtitles
- update_subtitles(sh_video, mpctx->d_sub, mpctx->video_offset, 0);
+ update_subtitles(mpctx, &mpctx->opts, sh_video, sh_video->pts,
+ mpctx->video_offset, mpctx->d_sub, 0);
update_teletext(sh_video, mpctx->demuxer, 0);
update_osd_msg(mpctx);
current_module = "filter video";
@@ -2580,7 +2603,9 @@ static int seek(MPContext *mpctx, double amount, int style)
// (which is used by at least vobsub and edl code below) may
// be completely wrong (probably 0).
mpctx->sh_video->pts = mpctx->d_video->pts + mpctx->video_offset;
- update_subtitles(mpctx->sh_video, mpctx->d_sub, mpctx->video_offset, 1);
+ update_subtitles(mpctx, &mpctx->opts, mpctx->sh_video,
+ mpctx->sh_video->pts, mpctx->video_offset,
+ mpctx->d_sub, 1);
update_teletext(mpctx->sh_video, mpctx->demuxer, 1);
}
@@ -2589,6 +2614,9 @@ 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(mpctx, &mpctx->opts, NULL, mpctx->sh_audio->pts,
+ mpctx->video_offset, mpctx->d_sub, 1);
}
if (vo_vobsub && mpctx->sh_video) {
@@ -3406,7 +3434,6 @@ if(stream_dump_type==5){
if(mpctx->stream->type==STREAMTYPE_DVD){
current_module="dvd lang->id";
if(opts->audio_id==-1) opts->audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang);
- if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
@@ -3419,7 +3446,6 @@ if(mpctx->stream->type==STREAMTYPE_DVD){
if(mpctx->stream->type==STREAMTYPE_DVDNAV){
current_module="dvdnav lang->id";
if(opts->audio_id==-1) opts->audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,audio_lang);
- if(dvdsub_lang && opts->sub_id==-2) opts->sub_id=-1;
if(dvdsub_lang && opts->sub_id==-1) opts->sub_id=mp_dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang);
// setup global sub numbering
mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub.
@@ -3668,14 +3694,14 @@ if(vo_spudec==NULL && mpctx->sh_video &&
init_vo_spudec(mpctx);
}
-if(mpctx->sh_video) {
// after reading video params we should load subtitles because
// we know fps so now we can adjust subtitle time to ~6 seconds AST
// check .sub
current_module="read_subtitles_file";
+ double sub_fps = mpctx->sh_video ? mpctx->sh_video->fps : 25;
if(sub_name){
for (i = 0; sub_name[i] != NULL; ++i)
- add_subtitles(mpctx, sub_name[i], mpctx->sh_video->fps, 0);
+ add_subtitles(mpctx, sub_name[i], sub_fps, 0);
}
if(sub_auto) { // auto load sub file ...
char *psub = get_path( "sub/" );
@@ -3683,7 +3709,7 @@ if(mpctx->sh_video) {
int i = 0;
free(psub); // release the buffer created by get_path() above
while (tmp[i]) {
- add_subtitles(mpctx, tmp[i], mpctx->sh_video->fps, 1);
+ add_subtitles(mpctx, tmp[i], sub_fps, 1);
free(tmp[i++]);
}
free(tmp);
@@ -3693,7 +3719,7 @@ if(mpctx->sh_video) {
mpctx->global_sub_indices[SUB_SOURCE_SUBS] = mpctx->global_sub_size; // the global # of the first sub.
mpctx->global_sub_size += mpctx->set_of_sub_size;
}
-}
+
if (mpctx->global_sub_size) {
// find the best sub to use
@@ -3708,11 +3734,11 @@ if (mpctx->global_sub_size) {
} else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) {
// if there are text subs to use, use those. (autosubs come last here)
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS];
- } else if (opts->sub_id < 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
+ } else if (opts->sub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
// finally select subs by language and container hints
- if (opts->sub_id < 0 && dvdsub_lang)
+ if (opts->sub_id == -1 && dvdsub_lang)
opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang);
- if (opts->sub_id < 0)
+ if (opts->sub_id == -1)
opts->sub_id = demuxer_default_sub_track(mpctx->demuxer);
if (opts->sub_id >= 0)
mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id;
@@ -3941,6 +3967,8 @@ if(!mpctx->sh_video) {
if(end_at.type == END_AT_TIME && end_at.pos < a_pos)
mpctx->stop_play = PT_NEXT_ENTRY;
+ update_subtitles(mpctx, &mpctx->opts, NULL, a_pos, mpctx->video_offset,
+ mpctx->d_sub, 0);
update_osd_msg(mpctx);
} else {