aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/FLACMetaData.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-10-02 11:24:05 +0200
committerMax Kellermann <max@duempel.org>2012-10-02 17:37:07 +0200
commitc645b906f32b5ed0f9b206ca5680b19983ce25e2 (patch)
tree366b6c54e1e0187fe483f2d2ef51a4f708a6eec2 /src/decoder/FLACMetaData.hxx
parent9c1d1ef2687050d7e0f9dd51d7e06d79321cda74 (diff)
downloadmpd-c645b906f32b5ed0f9b206ca5680b19983ce25e2.tar.gz
mpd-c645b906f32b5ed0f9b206ca5680b19983ce25e2.tar.xz
mpd-c645b906f32b5ed0f9b206ca5680b19983ce25e2.zip
decoder/flac: add C++ libFLAC wrappers
Not using libFLAC++ because this library adds a lot of overhead due to virtual method calls. This new class library is zero-overhead.
Diffstat (limited to '')
-rw-r--r--src/decoder/FLACMetaData.hxx64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/decoder/FLACMetaData.hxx b/src/decoder/FLACMetaData.hxx
index 6e8f0ef6e..d474def62 100644
--- a/src/decoder/FLACMetaData.hxx
+++ b/src/decoder/FLACMetaData.hxx
@@ -20,9 +20,71 @@
#ifndef MPD_FLAC_METADATA_H
#define MPD_FLAC_METADATA_H
+#include "gcc.h"
+
+#include <FLAC/metadata.h>
+
#include <assert.h>
#include <stdbool.h>
-#include <FLAC/metadata.h>
+
+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) {
+ return ::FLAC__metadata_chain_read(chain, path);
+ }
+
+ bool ReadOgg(const char *path) {
+ return ::FLAC__metadata_chain_read_ogg(chain, path);
+ }
+
+ gcc_pure
+ FLAC__Metadata_ChainStatus GetStatus() const {
+ return ::FLAC__metadata_chain_status(chain);
+ }
+
+ gcc_pure
+ const char *GetStatusString() const {
+ return FLAC__Metadata_ChainStatusString[GetStatus()];
+ }
+};
+
+class FLACMetadataIterator {
+ FLAC__Metadata_Iterator *iterator;
+
+public:
+ FLACMetadataIterator():iterator(::FLAC__metadata_iterator_new()) {}
+
+ FLACMetadataIterator(FLACMetadataChain &chain)
+ :iterator(::FLAC__metadata_iterator_new()) {
+ ::FLAC__metadata_iterator_init(iterator,
+ (FLAC__Metadata_Chain *)chain);
+ }
+
+ ~FLACMetadataIterator() {
+ ::FLAC__metadata_iterator_delete(iterator);
+ }
+
+ bool Next() {
+ return ::FLAC__metadata_iterator_next(iterator);
+ }
+
+ gcc_pure
+ FLAC__StreamMetadata *GetBlock() {
+ return ::FLAC__metadata_iterator_get_block(iterator);
+ }
+};
struct tag_handler;
struct tag;