aboutsummaryrefslogtreecommitdiff
path: root/src/decoder/FLACDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-10-04 07:09:31 +0200
committerMax Kellermann <max@duempel.org>2012-10-04 10:37:09 +0200
commitb8fdb452be9d79492b4bff84d2990cfcb1da282b (patch)
tree5353ba8365f4d4e3b19bfc78241343eac2637954 /src/decoder/FLACDecoderPlugin.cxx
parent6b416ce6be840dcd62aadb70817be602b5a73946 (diff)
decoder/flac: support FLAC files inside archives
Implement the "scan_stream" method that can read tags from any input_stream object. This requires a FLAC__IOCallbacks implementation based on the input_stream API.
Diffstat (limited to 'src/decoder/FLACDecoderPlugin.cxx')
-rw-r--r--src/decoder/FLACDecoderPlugin.cxx34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/decoder/FLACDecoderPlugin.cxx b/src/decoder/FLACDecoderPlugin.cxx
index b8d5173b..dbe7f207 100644
--- a/src/decoder/FLACDecoderPlugin.cxx
+++ b/src/decoder/FLACDecoderPlugin.cxx
@@ -101,6 +101,21 @@ flac_scan_file(const char *file,
return true;
}
+static bool
+flac_scan_stream(struct input_stream *is,
+ const struct tag_handler *handler, void *handler_ctx)
+{
+ FLACMetadataChain chain;
+ if (!chain.Read(is)) {
+ g_debug("Failed to read FLAC tags: %s",
+ chain.GetStatusString());
+ return false;
+ }
+
+ chain.Scan(handler, handler_ctx);
+ return true;
+}
+
/**
* Some glue code around FLAC__stream_decoder_new().
*/
@@ -297,6 +312,21 @@ oggflac_scan_file(const char *file,
return true;
}
+static bool
+oggflac_scan_stream(struct input_stream *is,
+ const struct tag_handler *handler, void *handler_ctx)
+{
+ FLACMetadataChain chain;
+ if (!chain.ReadOgg(is)) {
+ g_debug("Failed to read OggFLAC tags: %s",
+ chain.GetStatusString());
+ return false;
+ }
+
+ chain.Scan(handler, handler_ctx);
+ return true;
+}
+
static void
oggflac_decode(struct decoder *decoder, struct input_stream *input_stream)
{
@@ -327,7 +357,7 @@ const struct decoder_plugin oggflac_decoder_plugin = {
oggflac_decode,
nullptr,
oggflac_scan_file,
- nullptr,
+ oggflac_scan_stream,
nullptr,
oggflac_suffixes,
oggflac_mime_types,
@@ -349,7 +379,7 @@ const struct decoder_plugin flac_decoder_plugin = {
flac_decode,
nullptr,
flac_scan_file,
- nullptr,
+ flac_scan_stream,
nullptr,
flac_suffixes,
flac_mime_types,