diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-23 21:01:21 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-04-23 21:01:21 +0300 |
commit | 19907b8fbc0c958750c51d2d39739f37a8565ea4 (patch) | |
tree | 62d1f7f8fa00322f7ce101ee730cedb9a0f38d84 /libmpdemux/demuxer.c | |
parent | f9d224b1ad2f5488fe0fd1f581c4506a6067aa5a (diff) | |
download | mpv-19907b8fbc0c958750c51d2d39739f37a8565ea4.tar.bz2 mpv-19907b8fbc0c958750c51d2d39739f37a8565ea4.tar.xz |
demuxer.c: clean up stream-seek code
Only try to use the dvd/dvdnav stream seek hack with those stream
types. Generally demuxers can not be expected to cope with the stream
suddenly seeking under them. In principle it would be more correct to
make the test demuxer-based (instead of assuming that using stream
seeks in this manner is OK with whatever demuxer that will be used
with these streams), but that'd be more work.
Diffstat (limited to 'libmpdemux/demuxer.c')
-rw-r--r-- | libmpdemux/demuxer.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 0dafe16139..0f026dffd6 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1214,9 +1214,6 @@ void demux_flush(demuxer_t *demuxer) int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) { - double tmp = 0; - double pts; - if (!demuxer->seekable) { if (demuxer->file_format == DEMUXER_TYPE_AVI) mp_tmsg(MSGT_SEEK, MSGL_WARN, "Cannot seek in raw AVI streams. (Index required, try with the -idx switch.)\n"); @@ -1233,26 +1230,36 @@ int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, demuxer->video->eof = 0; demuxer->audio->eof = 0; - if (flags & SEEK_ABSOLUTE) - pts = 0.0f; - else { - if (demuxer->stream_pts == MP_NOPTS_VALUE) - goto dmx_seek; - pts = demuxer->stream_pts; - } - - if (flags & SEEK_FACTOR) { - if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &tmp) - == STREAM_UNSUPPORTED) - goto dmx_seek; - pts += tmp * rel_seek_secs; - } else - pts += rel_seek_secs; + /* HACK: assume any demuxer used with these streams can cope with + * the stream layer suddenly seeking to a different position under it + * (nothing actually implements DEMUXER_CTRL_RESYNC now). + */ + struct stream *stream = demuxer->stream; + if (stream->type == STREAMTYPE_DVD || stream->type == STREAMTYPE_DVDNAV) { + double pts; + + if (flags & SEEK_ABSOLUTE) + pts = 0.0f; + else { + if (demuxer->stream_pts == MP_NOPTS_VALUE) + goto dmx_seek; + pts = demuxer->stream_pts; + } - if (stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != - STREAM_UNSUPPORTED) { - demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); - return 1; + if (flags & SEEK_FACTOR) { + double tmp = 0; + if (stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, + &tmp) == STREAM_UNSUPPORTED) + goto dmx_seek; + pts += tmp * rel_seek_secs; + } else + pts += rel_seek_secs; + + if (stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) + != STREAM_UNSUPPORTED) { + demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); + return 1; + } } dmx_seek: |