aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins/OggFind.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-05-22 10:10:16 +0200
committerMax Kellermann <max@duempel.org>2014-05-22 13:52:00 +0200
commit07b93dcf8084bcae92fa1f33652723ca9c990db2 (patch)
tree5cfa3d13c14d68b70d54ade24169b84a7f614b8e /src/decoder/plugins/OggFind.cxx
parent374c6a27db790eb637feaeb9bd27ed82897d7953 (diff)
downloadmpd-07b93dcf8084bcae92fa1f33652723ca9c990db2.tar.gz
mpd-07b93dcf8084bcae92fa1f33652723ca9c990db2.tar.xz
mpd-07b93dcf8084bcae92fa1f33652723ca9c990db2.zip
InputStream: make Seek() always absolute
Remove the "whence" parameter that is not actually necessary, and only complicates the InputStream implementations.
Diffstat (limited to '')
-rw-r--r--src/decoder/plugins/OggFind.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/decoder/plugins/OggFind.cxx b/src/decoder/plugins/OggFind.cxx
index d7a3dc04a..15e9c5c92 100644
--- a/src/decoder/plugins/OggFind.cxx
+++ b/src/decoder/plugins/OggFind.cxx
@@ -22,8 +22,6 @@
#include "OggSyncState.hxx"
#include "util/Error.hxx"
-#include <stdio.h>
-
bool
OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
{
@@ -41,7 +39,7 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
bool
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
- InputStream::offset_type offset, int whence)
+ InputStream::offset_type offset)
{
oy.Reset();
@@ -49,7 +47,7 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
data */
ogg_stream_reset(&os);
- return is.LockSeek(offset, whence, IgnoreError()) &&
+ return is.LockSeek(offset, IgnoreError()) &&
oy.ExpectPageSeekIn(os);
}
@@ -57,12 +55,15 @@ bool
OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
InputStream &is)
{
- if (is.KnownSize() && is.GetRest() < 65536)
+ if (!is.KnownSize())
+ return false;
+
+ if (is.GetRest() < 65536)
return OggFindEOS(oy, os, packet);
if (!is.CheapSeeking())
return false;
- return OggSeekPageAtOffset(oy, os, is, -65536, SEEK_END) &&
+ return OggSeekPageAtOffset(oy, os, is, is.GetSize() - 65536) &&
OggFindEOS(oy, os, packet);
}