diff options
author | Max Kellermann <max@duempel.org> | 2013-10-24 20:33:12 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-24 20:33:12 +0200 |
commit | 92c85bd20dc4f55b53cc18887d4a6b9b165447ca (patch) | |
tree | d70a404b6c3caa335659f43d7ba9f7a1178f7f6a /src/decoder/OggFind.cxx | |
parent | f629eb8cb21377612c5c4453f495e5102b8c4803 (diff) | |
download | mpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.tar.gz mpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.tar.xz mpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.zip |
decoder/opus: move SeekFindEOS() to OggFind.cxx
Diffstat (limited to '')
-rw-r--r-- | src/decoder/OggFind.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/decoder/OggFind.cxx b/src/decoder/OggFind.cxx index 9df4c6455..297d925e7 100644 --- a/src/decoder/OggFind.cxx +++ b/src/decoder/OggFind.cxx @@ -20,6 +20,8 @@ #include "config.h" #include "OggFind.hxx" #include "OggSyncState.hxx" +#include "InputStream.hxx" +#include "util/Error.hxx" bool OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet) @@ -35,3 +37,20 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet) return true; } } + +bool +OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet, + InputStream &is) +{ + if (is.size > 0 && is.size - is.offset < 65536) + return OggFindEOS(oy, os, packet); + + if (!is.CheapSeeking()) + return false; + + oy.Reset(); + + return is.LockSeek(-65536, SEEK_END, IgnoreError()) && + oy.ExpectPageSeekIn(os) && + OggFindEOS(oy, os, packet); +} |