Commit 3c2d73d1 authored by Max Kellermann's avatar Max Kellermann

decoder/flac: add method FLACMetadataChain::Scan()

Merge common code.
parent 343de8b8
...@@ -373,15 +373,7 @@ oggflac_scan_file(const char *file, ...@@ -373,15 +373,7 @@ oggflac_scan_file(const char *file,
return false; return false;
} }
FLACMetadataIterator iterator(chain); chain.Scan(handler, handler_ctx);
do {
FLAC__StreamMetadata *block = iterator.GetBlock();
if (block == nullptr)
break;
flac_scan_metadata(block, handler, handler_ctx);
} while (iterator.Next());
return true; return true;
} }
......
...@@ -250,7 +250,15 @@ flac_scan_file2(const char *file, ...@@ -250,7 +250,15 @@ flac_scan_file2(const char *file,
return false; 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 { do {
FLAC__StreamMetadata *block = iterator.GetBlock(); FLAC__StreamMetadata *block = iterator.GetBlock();
if (block == nullptr) if (block == nullptr)
...@@ -258,6 +266,4 @@ flac_scan_file2(const char *file, ...@@ -258,6 +266,4 @@ flac_scan_file2(const char *file,
flac_scan_metadata(block, handler, handler_ctx); flac_scan_metadata(block, handler, handler_ctx);
} while (iterator.Next()); } while (iterator.Next());
return true;
} }
...@@ -58,6 +58,8 @@ public: ...@@ -58,6 +58,8 @@ public:
const char *GetStatusString() const { const char *GetStatusString() const {
return FLAC__Metadata_ChainStatusString[GetStatus()]; return FLAC__Metadata_ChainStatusString[GetStatus()];
} }
void Scan(const struct tag_handler *handler, void *handler_ctx);
}; };
class FLACMetadataIterator { class FLACMetadataIterator {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment