1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-18 13:47:04 +00:00

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.
This commit is contained in:
Uoti Urpala 2010-04-23 21:01:21 +03:00
parent f9d224b1ad
commit 19907b8fbc

View File

@ -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;
}
/* 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_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;
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: