decoder/flac: move class FlacMetadataChain to separate source
This commit is contained in:
parent
b153591790
commit
37897d1550
|
@ -1200,6 +1200,7 @@ if ENABLE_FLAC
|
|||
libdecoder_a_SOURCES += \
|
||||
src/lib/xiph/FlacMetadataIterator.hxx \
|
||||
src/lib/xiph/FlacIOHandle.cxx src/lib/xiph/FlacIOHandle.hxx \
|
||||
src/lib/xiph/FlacMetadataChain.cxx src/lib/xiph/FlacMetadataChain.hxx \
|
||||
src/decoder/plugins/FlacInput.cxx src/decoder/plugins/FlacInput.hxx \
|
||||
src/decoder/plugins/FlacMetadata.cxx src/decoder/plugins/FlacMetadata.hxx \
|
||||
src/decoder/plugins/FlacPcm.cxx src/decoder/plugins/FlacPcm.hxx \
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "FlacMetadataChain.hxx"
|
||||
#include "FlacMetadataIterator.hxx"
|
||||
#include "decoder/plugins/FlacMetadata.hxx"
|
||||
|
||||
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());
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_FLAC_METADATA_CHAIN_HXX
|
||||
#define MPD_FLAC_METADATA_CHAIN_HXX
|
||||
|
||||
#include "FlacIOHandle.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <FLAC/metadata.h>
|
||||
|
||||
class TagHandler;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue