decoder/flac: move class FlacMetadataChain to separate source

This commit is contained in:
Max Kellermann
2018-07-07 14:09:26 +02:00
parent b153591790
commit 37897d1550
7 changed files with 127 additions and 76 deletions

@@ -25,6 +25,7 @@
#include "FlacCommon.hxx"
#include "FlacMetadata.hxx"
#include "Log.hxx"
#include "input/InputStream.hxx"
#include <exception>

@@ -22,7 +22,7 @@
#include "FlacStreamDecoder.hxx"
#include "FlacDomain.hxx"
#include "FlacCommon.hxx"
#include "FlacMetadata.hxx"
#include "lib/xiph/FlacMetadataChain.hxx"
#include "OggCodec.hxx"
#include "fs/Path.hxx"
#include "fs/NarrowPath.hxx"

@@ -20,7 +20,6 @@
#include "config.h"
#include "FlacMetadata.hxx"
#include "lib/xiph/XiphTags.hxx"
#include "lib/xiph/FlacMetadataIterator.hxx"
#include "MixRampInfo.hxx"
#include "tag/Handler.hxx"
#include "tag/Table.hxx"
@@ -160,17 +159,3 @@ flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment)
flac_scan_comments(comment, h);
return tag_builder.Commit();
}
void
FlacMetadataChain::Scan(TagHandler &handler) noexcept
{
FlacMetadataIterator iterator(chain);
do {
FLAC__StreamMetadata *block = iterator.GetBlock();
if (block == nullptr)
break;
flac_scan_metadata(block, handler);
} while (iterator.Next());
}

@@ -20,71 +20,11 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
#include "Compiler.h"
#include "lib/xiph/FlacIOHandle.hxx"
#include <FLAC/metadata.h>
class TagHandler;
class MixRampInfo;
class FlacMetadataChain {
FLAC__Metadata_Chain *chain;
public:
FlacMetadataChain():chain(::FLAC__metadata_chain_new()) {}
~FlacMetadataChain() {
::FLAC__metadata_chain_delete(chain);
}
explicit operator FLAC__Metadata_Chain *() {
return chain;
}
bool Read(const char *path) noexcept {
return ::FLAC__metadata_chain_read(chain, path);
}
bool Read(FLAC__IOHandle handle,
FLAC__IOCallbacks callbacks) noexcept {
return ::FLAC__metadata_chain_read_with_callbacks(chain,
handle,
callbacks);
}
bool Read(InputStream &is) noexcept {
return Read(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
}
bool ReadOgg(const char *path) noexcept {
return ::FLAC__metadata_chain_read_ogg(chain, path);
}
bool ReadOgg(FLAC__IOHandle handle,
FLAC__IOCallbacks callbacks) noexcept {
return ::FLAC__metadata_chain_read_ogg_with_callbacks(chain,
handle,
callbacks);
}
bool ReadOgg(InputStream &is) {
return ReadOgg(::ToFlacIOHandle(is), ::GetFlacIOCallbacks(is));
}
gcc_pure
FLAC__Metadata_ChainStatus GetStatus() const noexcept {
return ::FLAC__metadata_chain_status(chain);
}
gcc_pure
const char *GetStatusString() const noexcept {
return FLAC__Metadata_ChainStatusString[GetStatus()];
}
void Scan(TagHandler &handler) noexcept;
};
struct Tag;
struct ReplayGainInfo;