aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-24 20:33:12 +0200
committerMax Kellermann <max@duempel.org>2013-10-24 20:33:12 +0200
commit92c85bd20dc4f55b53cc18887d4a6b9b165447ca (patch)
treed70a404b6c3caa335659f43d7ba9f7a1178f7f6a /src/decoder
parentf629eb8cb21377612c5c4453f495e5102b8c4803 (diff)
downloadmpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.tar.gz
mpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.tar.xz
mpd-92c85bd20dc4f55b53cc18887d4a6b9b165447ca.zip
decoder/opus: move SeekFindEOS() to OggFind.cxx
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/OggFind.cxx19
-rw-r--r--src/decoder/OggFind.hxx11
-rw-r--r--src/decoder/OpusDecoderPlugin.cxx20
3 files changed, 31 insertions, 19 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);
+}
diff --git a/src/decoder/OggFind.hxx b/src/decoder/OggFind.hxx
index 7d18d2067..703510fb5 100644
--- a/src/decoder/OggFind.hxx
+++ b/src/decoder/OggFind.hxx
@@ -24,6 +24,7 @@
#include <ogg/ogg.h>
+struct InputStream;
class OggSyncState;
/**
@@ -35,4 +36,14 @@ class OggSyncState;
bool
OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet);
+/**
+ * Try to find the end-of-stream (EOS) packet. Seek to the end of the
+ * file if necessary.
+ *
+ * @return true if the EOS packet was found
+ */
+bool
+OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
+ InputStream &is);
+
#endif
diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx
index 10a3d0b83..c90e31232 100644
--- a/src/decoder/OpusDecoderPlugin.cxx
+++ b/src/decoder/OpusDecoderPlugin.cxx
@@ -292,24 +292,6 @@ mpd_opus_stream_decode(Decoder &decoder,
}
static bool
-SeekFindEOS(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();
-
- Error error;
- return is.LockSeek(-65536, SEEK_END, error) &&
- oy.ExpectPageSeekIn(os) &&
- OggFindEOS(oy, os, packet);
-}
-
-static bool
mpd_opus_scan_stream(InputStream &is,
const struct tag_handler *handler, void *handler_ctx)
{
@@ -367,7 +349,7 @@ mpd_opus_scan_stream(InputStream &is,
}
}
- if (packet.e_o_s || SeekFindEOS(oy, os, packet, is))
+ if (packet.e_o_s || OggSeekFindEOS(oy, os, packet, is))
tag_handler_invoke_duration(handler, handler_ctx,
packet.granulepos / opus_sample_rate);