summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-16 00:27:53 +0200
committerwm4 <wm4@nowhere>2013-09-20 21:20:36 +0200
commitab816f1ab19bbe376c9aac7ec8920098ecea700d (patch)
tree73d94bc75d1db1c1f03afc26fef0e074ae5083ef
parent7b8d3602880869b16ae1fa036b76102d34aec923 (diff)
downloadmpv-ab816f1ab19bbe376c9aac7ec8920098ecea700d.tar.bz2
mpv-ab816f1ab19bbe376c9aac7ec8920098ecea700d.tar.xz
mplayer: read subtitle packets as soon as possible
Call update_subtitles() on every iteration of the playloop, so that subtitle packets are read as soon as possible, instead of every time a video frame is displayed. This helps in case the packet queue is swamped with subtitle packets, which can happen with certain insane mkv files. The change will simply cause the subtitle queue to be emptied on each playloop iteration. The timestamps update_subtitles() uses for display are the same before and after this commit. (Important for files which have subtitle packets with timestamps or duration not set.)
-rw-r--r--mpvcore/mplayer.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index d7e55fe1bc..7c8d33a6cd 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -1791,7 +1791,7 @@ static void reset_subtitles(struct MPContext *mpctx)
osd_changed(mpctx->osd, OSDTYPE_SUB);
}
-static void update_subtitles(struct MPContext *mpctx, double refpts_tl)
+static void update_subtitles(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
if (!(mpctx->initialized_flags & INITIALIZED_SUB))
@@ -1810,7 +1810,7 @@ static void update_subtitles(struct MPContext *mpctx, double refpts_tl)
mpctx->osd->video_offset = track->under_timeline ? mpctx->video_offset : 0;
- double refpts_s = refpts_tl - mpctx->osd->video_offset;
+ double refpts_s = mpctx->playback_pts - mpctx->osd->video_offset;
double curpts_s = refpts_s + opts->sub_delay;
if (!track->preloaded) {
@@ -2792,8 +2792,6 @@ static bool redraw_osd(struct MPContext *mpctx)
if (vo_redraw_frame(vo) < 0)
return false;
- if (mpctx->sh_video)
- update_subtitles(mpctx, mpctx->sh_video->pts);
draw_osd(mpctx);
vo_flip_page(vo, 0, -1);
@@ -3513,7 +3511,7 @@ static void run_playloop(struct MPContext *mpctx)
mpctx->video_pts = sh_video->pts;
mpctx->last_vo_pts = mpctx->video_pts;
mpctx->playback_pts = mpctx->video_pts;
- update_subtitles(mpctx, sh_video->pts);
+ update_subtitles(mpctx);
update_osd_msg(mpctx);
draw_osd(mpctx);
@@ -3600,11 +3598,10 @@ static void run_playloop(struct MPContext *mpctx)
}
mpctx->playback_pts = a_pos;
print_status(mpctx);
-
- if (!mpctx->sh_video)
- update_subtitles(mpctx, a_pos);
}
+ update_subtitles(mpctx);
+
/* It's possible for the user to simultaneously switch both audio
* and video streams to "disabled" at runtime. Handle this by waiting
* rather than immediately stopping playback due to EOF.