demux: seek to position 0 when loading, instead of restoring it

This was originally done for DVD/BD/DVB, where the start position could
be something different from 0, and seeking back to 0 would mess it up
completely.

Since we're not quite sure that these streams are unseekable, we can
simplify this somewhat, and also make sure we also start at 0 for normal
files. Helps a little bit with the following edition reloading commit.
This commit is contained in:
wm4 2014-10-28 15:28:46 +01:00
parent 98356b81b4
commit 0da9ee79e7
1 changed files with 7 additions and 7 deletions

View File

@ -844,13 +844,18 @@ static struct demuxer *open_given_type(struct mpv_global *global,
in->d_user->metadata = talloc_zero(in->d_user, struct mp_tags);
in->d_buffer->metadata = talloc_zero(in->d_buffer, struct mp_tags);
int64_t start_pos = stream_tell(stream);
mp_verbose(log, "Trying demuxer: %s (force-level: %s)\n",
desc->name, d_level(check));
in->d_thread->params = params; // temporary during open()
if (stream->seekable) // not for DVD/BD/DVB in particular
stream_seek(stream, 0);
// Peek this much data to avoid that stream_read() run by some demuxers
// or stream filters will flush previous peeked data.
stream_peek(stream, STREAM_BUFFER_SIZE);
int ret = demuxer->desc->open(in->d_thread, check);
if (ret >= 0) {
in->d_thread->params = NULL;
@ -873,7 +878,6 @@ static struct demuxer *open_given_type(struct mpv_global *global,
}
free_demuxer(demuxer);
stream_seek(stream, start_pos);
return NULL;
}
@ -909,10 +913,6 @@ struct demuxer *demux_open(struct stream *stream, char *force_format,
}
}
// Peek this much data to avoid that stream_read() run by some demuxers
// or stream filters will flush previous peeked data.
stream_peek(stream, STREAM_BUFFER_SIZE);
// Test demuxers from first to last, one pass for each check_levels[] entry
for (int pass = 0; check_levels[pass] != -1; pass++) {
enum demux_check level = check_levels[pass];