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

Merge common code.
This commit is contained in:
Max Kellermann 2012-10-02 18:24:15 +02:00
parent 343de8b8ab
commit 3c2d73d161
3 changed files with 12 additions and 12 deletions

View 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;
} }

View 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,
flac_scan_metadata(block, handler, handler_ctx); flac_scan_metadata(block, handler, handler_ctx);
} while (iterator.Next()); } while (iterator.Next());
return true;
} }

View File

@ -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 {