From 07b93dcf8084bcae92fa1f33652723ca9c990db2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 22 May 2014 10:10:16 +0200 Subject: InputStream: make Seek() always absolute Remove the "whence" parameter that is not actually necessary, and only complicates the InputStream implementations. --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/decoder/plugins/FfmpegDecoderPlugin.cxx') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 22a42477d..9139a622b 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -120,10 +120,29 @@ mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence) { AvioStream *stream = (AvioStream *)opaque; - if (whence == AVSEEK_SIZE) + switch (whence) { + case SEEK_SET: + break; + + case SEEK_CUR: + pos += stream->input.GetOffset(); + break; + + case SEEK_END: + if (!stream->input.KnownSize()) + return -1; + + pos += stream->input.GetSize(); + break; + + case AVSEEK_SIZE: return stream->input.GetSize(); - if (!stream->input.LockSeek(pos, whence, IgnoreError())) + default: + return -1; + } + + if (!stream->input.LockSeek(pos, IgnoreError())) return -1; return stream->input.GetOffset(); -- cgit v1.2.3