diff options
author | wm4 <wm4@nowhere> | 2016-02-28 19:14:23 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-02-28 19:28:34 +0100 |
commit | 92ba63079617f6579c276dd3ec54197b56378913 (patch) | |
tree | fff93c447a045a03cbc51ac4a0bac3a360220054 /demux/demux.c | |
parent | b638a413c37e8c892fcf40ca4ae29693f4942d0c (diff) | |
download | mpv-92ba63079617f6579c276dd3ec54197b56378913.tar.bz2 mpv-92ba63079617f6579c276dd3ec54197b56378913.tar.xz |
demux: remove relative seeking
Ever since a change in mplayer2 or so, relative seeks were translated to
absolute seeks before sending them to the demuxer in most cases. The
only exception in current mpv is DVD seeking.
Remove the SEEK_ABSOLUTE flag; it's not the implied default. SEEK_FACTOR
is kept, because it's sometimes slightly useful for seeking in things
like transport streams. (And maybe mkv files without duration set?)
DVD seeking is terrible because DVD and libdvdnav are terrible, but
mostly because libdvdnav is terrible. libdvdnav does not expose seeking
with seek tables. (Although I know xbmc/kodi use an undocumented API
that is not declared in the headers by dladdr()ing it - I think the
function is dvdnav_jump_to_sector_by_time().) With the current mpv
policy if not giving a shit about DVD, just revert our half-working seek
hacks and always use dvdnav_time_search(). Relative seeking might get
stuck sometimes; in this case --hr-seek=always is recommended.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/demux/demux.c b/demux/demux.c index fe72d3ef4c..05a8551608 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -580,8 +580,7 @@ static void start_refreshing(struct demux_internal *in) pthread_mutex_unlock(&in->lock); // Seek back to player's current position, with a small offset added. - in->d_thread->desc->seek(in->d_thread, start_ts - 1.0, - SEEK_ABSOLUTE | SEEK_BACKWARD | SEEK_HR); + in->d_thread->desc->seek(in->d_thread, start_ts - 1.0, SEEK_BACKWARD | SEEK_HR); pthread_mutex_lock(&in->lock); } @@ -947,7 +946,6 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src) dst->partially_seekable = src->partially_seekable; dst->filetype = src->filetype; dst->ts_resets_possible = src->ts_resets_possible; - dst->rel_seeks = src->rel_seeks; dst->allow_refresh_seeks = src->allow_refresh_seeks; dst->fully_read = src->fully_read; dst->start_time = src->start_time; @@ -1240,7 +1238,7 @@ void demux_flush(demuxer_t *demuxer) pthread_mutex_unlock(&demuxer->in->lock); } -int demux_seek(demuxer_t *demuxer, double rel_seek_secs, int flags) +int demux_seek(demuxer_t *demuxer, double seek_pts, int flags) { struct demux_internal *in = demuxer->in; assert(demuxer == in->d_user); @@ -1250,32 +1248,22 @@ int demux_seek(demuxer_t *demuxer, double rel_seek_secs, int flags) return 0; } - if ((flags & SEEK_FACTOR) && !(flags & SEEK_ABSOLUTE)) { - MP_WARN(demuxer, "Invalid seek flags.\n"); - return 0; - } - - if (rel_seek_secs == MP_NOPTS_VALUE && (flags & SEEK_ABSOLUTE)) + if (seek_pts == MP_NOPTS_VALUE) return 0; - if (!(flags & (SEEK_BACKWARD | SEEK_FORWARD))) { - if (flags & SEEK_ABSOLUTE || rel_seek_secs < 0) { - flags |= SEEK_BACKWARD; - } else { - flags |= SEEK_FORWARD; - } - } + if (!(flags & SEEK_FORWARD)) + flags |= SEEK_BACKWARD; pthread_mutex_lock(&in->lock); - MP_VERBOSE(in, "queuing seek to %f%s\n", rel_seek_secs, + MP_VERBOSE(in, "queuing seek to %f%s\n", seek_pts, in->seeking ? " (cascade)" : ""); flush_locked(demuxer); in->seeking = true; in->seek_flags = flags; - in->seek_pts = rel_seek_secs; - if ((flags & SEEK_ABSOLUTE) && !(flags & SEEK_FACTOR)) + in->seek_pts = seek_pts; + if (!(flags & SEEK_FACTOR)) in->seek_pts = MP_ADD_PTS(in->seek_pts, -in->ts_offset); if (!in->threading) |