summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-13 20:05:25 +0200
committerwm4 <wm4@nowhere>2014-07-13 20:05:25 +0200
commitb505cab59742dd47125153e63c690bf6ef591f61 (patch)
tree7b5530ac05706b07052d0580465a77a60e909fe0 /demux
parent1f98bb3adcaf261b8316dfd0e19d64c23d4e1467 (diff)
downloadmpv-b505cab59742dd47125153e63c690bf6ef591f61.tar.bz2
mpv-b505cab59742dd47125153e63c690bf6ef591f61.tar.xz
dvdnav: fix time display when starting in the middle of the DVD
libdvdnav can actually jump into the middle of the DVD (e.g. scene selection menus do that). Then time display is incorrect: we start from 0, even though playback time is somewhere else. This really matters when seeking. If the display time mismatches, a small relative seek will apparently jump to the beginning of the movie. Fix this by initializing the PTS stuff on opening. We have to do this after some small amount of data has been read from the stream (because libdvdnav is crap and doesn't always update the time between seeks and the first read; also see STREAM_CTRL_GET_CURRENT_TIME remarks in cache.c; although this was not observed when testing with scene selection menus). On the other hand, we want to do it before opening the demuxer, because that will read large amounts of data and likely will change the stream position. Also see commit 49813670.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_disc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/demux/demux_disc.c b/demux/demux_disc.c
index d433550908..06cea65d1a 100644
--- a/demux/demux_disc.c
+++ b/demux/demux_disc.c
@@ -285,6 +285,11 @@ static int d_open(demuxer_t *demuxer, enum demux_check check)
if (demuxer->stream->uncached_type == STREAMTYPE_CDDA)
demux = "+rawaudio";
+ // Initialize the playback time. We need to read _some_ data to get the
+ // correct stream-layer time (at least with libdvdnav).
+ stream_peek(demuxer->stream, 1);
+ reset_pts(demuxer);
+
p->slave = demux_open(demuxer->stream, demux, NULL, demuxer->global);
if (!p->slave)
return -1;