From 3c2d73d161814a1cac543f2623671feb0b7c8fe9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Oct 2012 18:24:15 +0200 Subject: [PATCH] decoder/flac: add method FLACMetadataChain::Scan() Merge common code. --- src/decoder/FLACDecoderPlugin.cxx | 10 +--------- src/decoder/FLACMetaData.cxx | 12 +++++++++--- src/decoder/FLACMetaData.hxx | 2 ++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/decoder/FLACDecoderPlugin.cxx b/src/decoder/FLACDecoderPlugin.cxx index 5de0ccef3..6bcc26c17 100644 --- a/src/decoder/FLACDecoderPlugin.cxx +++ b/src/decoder/FLACDecoderPlugin.cxx @@ -373,15 +373,7 @@ oggflac_scan_file(const char *file, return false; } - FLACMetadataIterator iterator(chain); - do { - FLAC__StreamMetadata *block = iterator.GetBlock(); - if (block == nullptr) - break; - - flac_scan_metadata(block, handler, handler_ctx); - } while (iterator.Next()); - + chain.Scan(handler, handler_ctx); return true; } diff --git a/src/decoder/FLACMetaData.cxx b/src/decoder/FLACMetaData.cxx index 56c8a2764..8d70f149e 100644 --- a/src/decoder/FLACMetaData.cxx +++ b/src/decoder/FLACMetaData.cxx @@ -250,7 +250,15 @@ flac_scan_file2(const char *file, return false; } - FLACMetadataIterator iterator(chain); + chain.Scan(handler, handler_ctx); + return true; +} + +void +FLACMetadataChain::Scan(const struct tag_handler *handler, void *handler_ctx) +{ + FLACMetadataIterator iterator(*this); + do { FLAC__StreamMetadata *block = iterator.GetBlock(); if (block == nullptr) @@ -258,6 +266,4 @@ flac_scan_file2(const char *file, flac_scan_metadata(block, handler, handler_ctx); } while (iterator.Next()); - - return true; } diff --git a/src/decoder/FLACMetaData.hxx b/src/decoder/FLACMetaData.hxx index d474def62..67dc9fcd7 100644 --- a/src/decoder/FLACMetaData.hxx +++ b/src/decoder/FLACMetaData.hxx @@ -58,6 +58,8 @@ public: const char *GetStatusString() const { return FLAC__Metadata_ChainStatusString[GetStatus()]; } + + void Scan(const struct tag_handler *handler, void *handler_ctx); }; class FLACMetadataIterator {