decoder/opus: move code to OggSeekPageAtOffset()

This commit is contained in:
Max Kellermann 2013-10-24 20:40:23 +02:00
parent 92c85bd20d
commit dc328e0c4a

View File

@ -38,6 +38,16 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
} }
} }
static bool
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
InputStream::offset_type offset, int whence)
{
oy.Reset();
return is.LockSeek(offset, whence, IgnoreError()) &&
oy.ExpectPageSeekIn(os);
}
bool bool
OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet, OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
InputStream &is) InputStream &is)
@ -48,9 +58,6 @@ OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
if (!is.CheapSeeking()) if (!is.CheapSeeking())
return false; return false;
oy.Reset(); return OggSeekPageAtOffset(oy, os, is, -65536, SEEK_END) &&
return is.LockSeek(-65536, SEEK_END, IgnoreError()) &&
oy.ExpectPageSeekIn(os) &&
OggFindEOS(oy, os, packet); OggFindEOS(oy, os, packet);
} }