diff --git a/src/lib/xiph/OggFind.cxx b/src/lib/xiph/OggFind.cxx index e31bd9514..583d5fad0 100644 --- a/src/lib/xiph/OggFind.cxx +++ b/src/lib/xiph/OggFind.cxx @@ -57,13 +57,14 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is, bool OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet, - InputStream &is) + InputStream &is, bool synced) { if (!is.KnownSize()) return false; if (is.GetRest() < 65536) - return OggFindEOS(oy, os, packet); + return (synced || oy.ExpectPageSeekIn(os)) && + OggFindEOS(oy, os, packet); if (!is.CheapSeeking()) return false; diff --git a/src/lib/xiph/OggFind.hxx b/src/lib/xiph/OggFind.hxx index 051237900..a8ddf60f3 100644 --- a/src/lib/xiph/OggFind.hxx +++ b/src/lib/xiph/OggFind.hxx @@ -47,10 +47,13 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is, * Try to find the end-of-stream (EOS) packet. Seek to the end of the * file if necessary. * + * @param synced is the #OggSyncState currently synced? If not, then + * we need to use ogg_sync_pageseek() instead of ogg_sync_pageout(), + * which is more expensive * @return true if the EOS packet was found */ bool OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet, - InputStream &is); + InputStream &is, bool synced=true); #endif