aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/FLACMetaData.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/FLACMetaData.cxx (renamed from src/decoder/flac_metadata.c)51
1 files changed, 18 insertions, 33 deletions
diff --git a/src/decoder/flac_metadata.c b/src/decoder/FLACMetaData.cxx
index bd1eaf323..b1d82a93d 100644
--- a/src/decoder/flac_metadata.c
+++ b/src/decoder/FLACMetaData.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2012 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,9 +18,14 @@
*/
#include "config.h"
-#include "flac_metadata.h"
+#include "FLACMetaData.hxx"
+
+extern "C" {
+#include "XiphTags.h"
#include "replay_gain_info.h"
#include "tag.h"
+}
+
#include "tag_handler.h"
#include "tag_table.h"
@@ -91,7 +96,7 @@ flac_find_string_comment(const FLAC__StreamMetadata *block,
int len;
const unsigned char *p;
- *str = NULL;
+ *str = nullptr;
offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
cmnt);
if (offset < 0)
@@ -136,9 +141,9 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
if (entry->length <= name_length ||
g_ascii_strncasecmp(comment, name, name_length) != 0)
- return NULL;
+ return nullptr;
- if (char_tnum != NULL) {
+ if (char_tnum != nullptr) {
char_tnum_length = strlen(char_tnum);
if (entry->length > name_length + char_tnum_length + 2 &&
comment[name_length] == '[' &&
@@ -157,7 +162,7 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
return comment + name_length + 1;
}
- return NULL;
+ return nullptr;
}
/**
@@ -174,7 +179,7 @@ flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
size_t value_length;
value = flac_comment_value(entry, name, char_tnum, &value_length);
- if (value != NULL) {
+ if (value != nullptr) {
char *p = g_strndup(value, value_length);
tag_handler_invoke_tag(handler, handler_ctx, tag_type, p);
g_free(p);
@@ -184,23 +189,16 @@ flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
return false;
}
-static const struct tag_table flac_tags[] = {
- { "tracknumber", TAG_TRACK },
- { "discnumber", TAG_DISC },
- { "album artist", TAG_ALBUM_ARTIST },
- { NULL, TAG_NUM_OF_ITEM_TYPES }
-};
-
static void
flac_scan_comment(const char *char_tnum,
const FLAC__StreamMetadata_VorbisComment_Entry *entry,
const struct tag_handler *handler, void *handler_ctx)
{
- if (handler->pair != NULL) {
+ if (handler->pair != nullptr) {
char *name = g_strdup((const char*)entry->entry);
char *value = strchr(name, '=');
- if (value != NULL && value > name) {
+ if (value != nullptr && value > name) {
*value++ = 0;
tag_handler_invoke_pair(handler, handler_ctx,
name, value);
@@ -209,14 +207,15 @@ flac_scan_comment(const char *char_tnum,
g_free(name);
}
- for (const struct tag_table *i = flac_tags; i->name != NULL; ++i)
+ for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
if (flac_copy_comment(entry, i->name, i->type, char_tnum,
handler, handler_ctx))
return;
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
if (flac_copy_comment(entry,
- tag_item_names[i], i, char_tnum,
+ tag_item_names[i], (enum tag_type)i,
+ char_tnum,
handler, handler_ctx))
return;
}
@@ -266,7 +265,7 @@ flac_scan_file2(const char *file, const char *char_tnum,
const struct tag_handler *handler, void *handler_ctx)
{
FLAC__Metadata_SimpleIterator *it;
- FLAC__StreamMetadata *block = NULL;
+ FLAC__StreamMetadata *block = nullptr;
it = FLAC__metadata_simple_iterator_new();
if (!FLAC__metadata_simple_iterator_init(it, file, 1, 0)) {
@@ -307,17 +306,3 @@ flac_scan_file2(const char *file, const char *char_tnum,
return true;
}
-
-struct tag *
-flac_tag_load(const char *file, const char *char_tnum)
-{
- struct tag *tag = tag_new();
-
- if (!flac_scan_file2(file, char_tnum, &add_tag_handler, tag) ||
- tag_is_empty(tag)) {
- tag_free(tag);
- tag = NULL;
- }
-
- return tag;
-}