aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag
diff options
context:
space:
mode:
Diffstat (limited to 'src/tag')
-rw-r--r--src/tag/Aiff.cxx2
-rw-r--r--src/tag/Aiff.hxx2
-rw-r--r--src/tag/ApeLoader.cxx2
-rw-r--r--src/tag/ApeLoader.hxx2
-rw-r--r--src/tag/ApeReplayGain.cxx2
-rw-r--r--src/tag/ApeReplayGain.hxx2
-rw-r--r--src/tag/ApeTag.cxx3
-rw-r--r--src/tag/ApeTag.hxx2
-rw-r--r--src/tag/Format.cxx133
-rw-r--r--src/tag/Format.hxx32
-rw-r--r--src/tag/MixRamp.cxx2
-rw-r--r--src/tag/MixRamp.hxx2
-rw-r--r--src/tag/ReplayGain.cxx2
-rw-r--r--src/tag/ReplayGain.hxx2
-rw-r--r--src/tag/Riff.cxx2
-rw-r--r--src/tag/Riff.hxx2
-rw-r--r--src/tag/Set.cxx4
-rw-r--r--src/tag/Set.hxx2
-rw-r--r--src/tag/Tag.cxx2
-rw-r--r--src/tag/Tag.hxx2
-rw-r--r--src/tag/TagBuilder.cxx2
-rw-r--r--src/tag/TagBuilder.hxx2
-rw-r--r--src/tag/TagConfig.cxx5
-rw-r--r--src/tag/TagConfig.hxx2
-rw-r--r--src/tag/TagHandler.cxx2
-rw-r--r--src/tag/TagHandler.hxx2
-rw-r--r--src/tag/TagId3.cxx10
-rw-r--r--src/tag/TagId3.hxx4
-rw-r--r--src/tag/TagItem.hxx2
-rw-r--r--src/tag/TagNames.c2
-rw-r--r--src/tag/TagPool.cxx4
-rw-r--r--src/tag/TagPool.hxx2
-rw-r--r--src/tag/TagRva2.cxx44
-rw-r--r--src/tag/TagRva2.hxx2
-rw-r--r--src/tag/TagSettings.c2
-rw-r--r--src/tag/TagSettings.h2
-rw-r--r--src/tag/TagString.cxx2
-rw-r--r--src/tag/TagString.hxx2
-rw-r--r--src/tag/TagTable.cxx2
-rw-r--r--src/tag/TagTable.hxx2
-rw-r--r--src/tag/TagType.h2
-rw-r--r--src/tag/VorbisComment.cxx2
-rw-r--r--src/tag/VorbisComment.hxx2
43 files changed, 238 insertions, 69 deletions
diff --git a/src/tag/Aiff.cxx b/src/tag/Aiff.cxx
index c2498c9e9..7235b76a8 100644
--- a/src/tag/Aiff.cxx
+++ b/src/tag/Aiff.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Aiff.hxx b/src/tag/Aiff.hxx
index cd323ee2e..f9b11b5a6 100644
--- a/src/tag/Aiff.hxx
+++ b/src/tag/Aiff.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx
index f473c910e..786ecfe8f 100644
--- a/src/tag/ApeLoader.cxx
+++ b/src/tag/ApeLoader.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ApeLoader.hxx b/src/tag/ApeLoader.hxx
index ce82cc35d..1bdfe692d 100644
--- a/src/tag/ApeLoader.hxx
+++ b/src/tag/ApeLoader.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ApeReplayGain.cxx b/src/tag/ApeReplayGain.cxx
index 345f45710..139d44d1f 100644
--- a/src/tag/ApeReplayGain.cxx
+++ b/src/tag/ApeReplayGain.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ApeReplayGain.hxx b/src/tag/ApeReplayGain.hxx
index 03c899c5c..faf68f0e3 100644
--- a/src/tag/ApeReplayGain.hxx
+++ b/src/tag/ApeReplayGain.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ApeTag.cxx b/src/tag/ApeTag.cxx
index f714a1624..49ae7a036 100644
--- a/src/tag/ApeTag.cxx
+++ b/src/tag/ApeTag.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,6 @@
#include <string.h>
const struct tag_table ape_tags[] = {
- { "album artist", TAG_ALBUM_ARTIST },
{ "year", TAG_DATE },
{ nullptr, TAG_NUM_OF_ITEM_TYPES }
};
diff --git a/src/tag/ApeTag.hxx b/src/tag/ApeTag.hxx
index edebf076c..20d1d7b81 100644
--- a/src/tag/ApeTag.hxx
+++ b/src/tag/ApeTag.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Format.cxx b/src/tag/Format.cxx
new file mode 100644
index 000000000..de4db57ef
--- /dev/null
+++ b/src/tag/Format.cxx
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2003-2015 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 "Format.hxx"
+#include "Tag.hxx"
+#include "util/format.h"
+#include "util/StringUtil.hxx"
+
+#include <algorithm>
+
+#include <string.h>
+#include <time.h>
+
+struct FormatTagContext {
+ const Tag &tag;
+
+ char buffer[256];
+
+ explicit FormatTagContext(const Tag &_tag):tag(_tag) {}
+};
+
+/**
+ * Is this a character unsafe to use in a path name segment?
+ */
+static constexpr bool
+IsUnsafeChar(char ch)
+{
+ return
+ /* disallow characters illegal in file names on
+ Windows (Linux allows almost anything) */
+ ch == '\\' || ch == '/' || ch == ':' || ch == '*' ||
+ ch == '?' || ch == '<' || ch == '>' || ch == '|' ||
+ /* allow space, but disallow all other whitespace */
+ (unsigned char)ch < 0x20;
+}
+
+gcc_pure
+static bool
+HasUnsafeChar(const char *s)
+{
+ for (; *s; ++s)
+ if (IsUnsafeChar(*s))
+ return true;
+
+ return false;
+}
+
+static const char *
+SanitizeString(const char *s, char *buffer, size_t buffer_size)
+{
+ /* skip leading dots to avoid generating "../" sequences */
+ while (*s == '.')
+ ++s;
+
+ if (!HasUnsafeChar(s))
+ return s;
+
+ char *end = CopyString(buffer, s, buffer_size);
+ std::replace_if(buffer, end, IsUnsafeChar, ' ');
+ return buffer;
+}
+
+gcc_pure gcc_nonnull_all
+static const char *
+TagGetter(const void *object, const char *name)
+{
+ const auto &_ctx = *(const FormatTagContext *)object;
+ auto &ctx = const_cast<FormatTagContext &>(_ctx);
+
+ if (strcmp(name, "iso8601") == 0) {
+ time_t t = time(nullptr);
+#ifdef WIN32
+ const struct tm *tm2 = gmtime(&t);
+#else
+ struct tm tm;
+ const struct tm *tm2 = gmtime_r(&t, &tm);
+#endif
+ if (tm2 == nullptr)
+ return "";
+
+ strftime(ctx.buffer, sizeof(ctx.buffer),
+#ifdef WIN32
+ /* kludge: use underscore instead of colon on
+ Windows because colons are not allowed in
+ file names, and this library is mostly
+ used to generate file names */
+ "%Y-%m-%dT%H_%M_%SZ",
+#else
+ "%FT%TZ",
+#endif
+ tm2);
+ return ctx.buffer;
+ }
+
+ const Tag &tag = ctx.tag;
+
+ TagType tag_type = tag_name_parse_i(name);
+ if (tag_type == TAG_NUM_OF_ITEM_TYPES)
+ /* unknown tag name */
+ return nullptr;
+
+ const char *value = tag.GetValue(tag_type);
+ if (value == nullptr)
+ /* known tag name, but not present in this object */
+ value = "";
+
+ // TODO: handle multiple tag values
+ return SanitizeString(value, ctx.buffer, sizeof(ctx.buffer));
+}
+
+char *
+FormatTag(const Tag &tag, const char *format)
+{
+ FormatTagContext ctx(tag);
+ return format_object(format, &ctx, TagGetter);
+}
diff --git a/src/tag/Format.hxx b/src/tag/Format.hxx
new file mode 100644
index 000000000..a08e687d0
--- /dev/null
+++ b/src/tag/Format.hxx
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2003-2015 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_TAG_FORMAT_HXX
+#define MPD_TAG_FORMAT_HXX
+
+#include "check.h"
+#include "Compiler.h"
+
+struct Tag;
+
+gcc_malloc gcc_nonnull_all
+char *
+FormatTag(const Tag &tag, const char *format);
+
+#endif
diff --git a/src/tag/MixRamp.cxx b/src/tag/MixRamp.cxx
index e1b6e43c5..cbec047de 100644
--- a/src/tag/MixRamp.cxx
+++ b/src/tag/MixRamp.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/MixRamp.hxx b/src/tag/MixRamp.hxx
index 5b4e2dc30..7255bac4d 100644
--- a/src/tag/MixRamp.hxx
+++ b/src/tag/MixRamp.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ReplayGain.cxx b/src/tag/ReplayGain.cxx
index 83a48f243..edf8c92f1 100644
--- a/src/tag/ReplayGain.cxx
+++ b/src/tag/ReplayGain.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/ReplayGain.hxx b/src/tag/ReplayGain.hxx
index 2bf5e0db1..a2e897235 100644
--- a/src/tag/ReplayGain.hxx
+++ b/src/tag/ReplayGain.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Riff.cxx b/src/tag/Riff.cxx
index c630f082d..741225813 100644
--- a/src/tag/Riff.cxx
+++ b/src/tag/Riff.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Riff.hxx b/src/tag/Riff.hxx
index a9af67b7a..b15716882 100644
--- a/src/tag/Riff.hxx
+++ b/src/tag/Riff.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Set.cxx b/src/tag/Set.cxx
index 6a55a450f..22d1728ad 100644
--- a/src/tag/Set.cxx
+++ b/src/tag/Set.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -75,7 +75,7 @@ TagSet::InsertUnique(const Tag &src, TagType type, const char *value,
else
builder.AddItem(type, value);
CopyTagMask(builder, src, group_mask);
-#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
+#if CLANG_OR_GCC_VERSION(4,8)
emplace(builder.Commit());
#else
insert(builder.Commit());
diff --git a/src/tag/Set.hxx b/src/tag/Set.hxx
index b5acfcb36..aab994008 100644
--- a/src/tag/Set.hxx
+++ b/src/tag/Set.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Tag.cxx b/src/tag/Tag.cxx
index 92ac4214c..571e67fa8 100644
--- a/src/tag/Tag.cxx
+++ b/src/tag/Tag.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Tag.hxx b/src/tag/Tag.hxx
index f1d3d5767..aca2bf6a0 100644
--- a/src/tag/Tag.hxx
+++ b/src/tag/Tag.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagBuilder.cxx b/src/tag/TagBuilder.cxx
index 0882f9561..42e11e798 100644
--- a/src/tag/TagBuilder.cxx
+++ b/src/tag/TagBuilder.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagBuilder.hxx b/src/tag/TagBuilder.hxx
index aff581313..19186ab75 100644
--- a/src/tag/TagBuilder.hxx
+++ b/src/tag/TagBuilder.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagConfig.cxx b/src/tag/TagConfig.cxx
index 00f20d1c0..df40c2bc0 100644
--- a/src/tag/TagConfig.cxx
+++ b/src/tag/TagConfig.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,8 @@
void
TagLoadConfig()
{
- const char *value = config_get_string(CONF_METADATA_TO_USE, nullptr);
+ const char *value = config_get_string(ConfigOption::METADATA_TO_USE,
+ nullptr);
if (value == nullptr)
return;
diff --git a/src/tag/TagConfig.hxx b/src/tag/TagConfig.hxx
index 0088e9757..05c6594c6 100644
--- a/src/tag/TagConfig.hxx
+++ b/src/tag/TagConfig.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx
index 2cbb83242..9bbaae36a 100644
--- a/src/tag/TagHandler.cxx
+++ b/src/tag/TagHandler.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagHandler.hxx b/src/tag/TagHandler.hxx
index c12b605bc..e87c299fc 100644
--- a/src/tag/TagHandler.hxx
+++ b/src/tag/TagHandler.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagId3.cxx b/src/tag/TagId3.cxx
index 02dc58364..ade1fd007 100644
--- a/src/tag/TagId3.cxx
+++ b/src/tag/TagId3.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -66,12 +66,14 @@
static constexpr Domain id3_domain("id3");
+gcc_pure
static inline bool
tag_is_id3v1(struct id3_tag *tag)
{
return (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) != 0;
}
+gcc_pure
static id3_utf8_t *
tag_id3_getstring(const struct id3_frame *frame, unsigned i)
{
@@ -97,7 +99,8 @@ import_id3_string(bool is_id3v1, const id3_ucs4_t *ucs4)
/* use encoding field here? */
const char *encoding;
if (is_id3v1 &&
- (encoding = config_get_string(CONF_ID3V1_ENCODING, nullptr)) != nullptr) {
+ (encoding = config_get_string(ConfigOption::ID3V1_ENCODING,
+ nullptr)) != nullptr) {
id3_latin1_t *isostr = id3_ucs4_latin1duplicate(ucs4);
if (gcc_unlikely(isostr == nullptr))
return nullptr;
@@ -249,10 +252,11 @@ tag_id3_import_comment(struct id3_tag *tag, const char *id, TagType type,
* Parse a TXXX name, and convert it to a TagType enum value.
* Returns TAG_NUM_OF_ITEM_TYPES if the TXXX name is not understood.
*/
+gcc_pure
static TagType
tag_id3_parse_txxx_name(const char *name)
{
- static const struct tag_table txxx_tags[] = {
+ static constexpr struct tag_table txxx_tags[] = {
{ "ALBUMARTISTSORT", TAG_ALBUM_ARTIST_SORT },
{ "MusicBrainz Artist Id", TAG_MUSICBRAINZ_ARTISTID },
{ "MusicBrainz Album Id", TAG_MUSICBRAINZ_ALBUMID },
diff --git a/src/tag/TagId3.hxx b/src/tag/TagId3.hxx
index 1928d539d..94dfb1794 100644
--- a/src/tag/TagId3.hxx
+++ b/src/tag/TagId3.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -29,7 +29,7 @@ struct Tag;
struct id3_tag;
class Error;
-#ifdef HAVE_ID3TAG
+#ifdef ENABLE_ID3TAG
bool
tag_id3_scan(Path path_fs,
diff --git a/src/tag/TagItem.hxx b/src/tag/TagItem.hxx
index 489ecde3a..0aa52f700 100644
--- a/src/tag/TagItem.hxx
+++ b/src/tag/TagItem.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagNames.c b/src/tag/TagNames.c
index e051c5863..056d714e4 100644
--- a/src/tag/TagNames.c
+++ b/src/tag/TagNames.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagPool.cxx b/src/tag/TagPool.cxx
index 29f605337..0280948fd 100644
--- a/src/tag/TagPool.cxx
+++ b/src/tag/TagPool.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -87,7 +87,7 @@ calc_hash(TagType type, const char *p)
return hash ^ type;
}
-#if defined(__clang__) || GCC_CHECK_VERSION(4,7)
+#if CLANG_OR_GCC_VERSION(4,7)
constexpr
#endif
static inline TagPoolSlot *
diff --git a/src/tag/TagPool.hxx b/src/tag/TagPool.hxx
index 990ee87bd..7fba85b54 100644
--- a/src/tag/TagPool.hxx
+++ b/src/tag/TagPool.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagRva2.cxx b/src/tag/TagRva2.cxx
index bbb6d11e6..8e22cd693 100644
--- a/src/tag/TagRva2.cxx
+++ b/src/tag/TagRva2.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -26,42 +26,42 @@
#include <stdint.h>
#include <string.h>
-enum rva2_channel {
- CHANNEL_OTHER = 0x00,
- CHANNEL_MASTER_VOLUME = 0x01,
- CHANNEL_FRONT_RIGHT = 0x02,
- CHANNEL_FRONT_LEFT = 0x03,
- CHANNEL_BACK_RIGHT = 0x04,
- CHANNEL_BACK_LEFT = 0x05,
- CHANNEL_FRONT_CENTRE = 0x06,
- CHANNEL_BACK_CENTRE = 0x07,
- CHANNEL_SUBWOOFER = 0x08
+enum class Rva2Channel : uint8_t {
+ OTHER = 0x00,
+ MASTER_VOLUME = 0x01,
+ FRONT_RIGHT = 0x02,
+ FRONT_LEFT = 0x03,
+ BACK_RIGHT = 0x04,
+ BACK_LEFT = 0x05,
+ FRONT_CENTRE = 0x06,
+ BACK_CENTRE = 0x07,
+ SUBWOOFER = 0x08
};
-struct rva2_data {
- uint8_t type;
+struct Rva2Data {
+ Rva2Channel type;
uint8_t volume_adjustment[2];
uint8_t peak_bits;
};
static inline id3_length_t
-rva2_peak_bytes(const struct rva2_data *data)
+rva2_peak_bytes(const Rva2Data &data)
{
- return (data->peak_bits + 7) / 8;
+ return (data.peak_bits + 7) / 8;
}
static inline int
-rva2_fixed_volume_adjustment(const struct rva2_data *data)
+rva2_fixed_volume_adjustment(const Rva2Data &data)
{
signed int voladj_fixed;
- voladj_fixed = (data->volume_adjustment[0] << 8) |
- data->volume_adjustment[1];
+ voladj_fixed = (data.volume_adjustment[0] << 8) |
+ data.volume_adjustment[1];
voladj_fixed |= -(voladj_fixed & 0x8000);
return voladj_fixed;
}
static inline float
-rva2_float_volume_adjustment(const struct rva2_data *data)
+rva2_float_volume_adjustment(const Rva2Data &data)
{
/*
* "The volume adjustment is encoded as a fixed point decibel
@@ -74,9 +74,9 @@ rva2_float_volume_adjustment(const struct rva2_data *data)
static inline bool
rva2_apply_data(ReplayGainInfo &rgi,
- const struct rva2_data *data, const id3_latin1_t *id)
+ const Rva2Data &data, const id3_latin1_t *id)
{
- if (data->type != CHANNEL_MASTER_VOLUME)
+ if (data.type != Rva2Channel::MASTER_VOLUME)
return false;
float volume_adjustment = rva2_float_volume_adjustment(data);
@@ -117,7 +117,7 @@ rva2_apply_frame(ReplayGainInfo &replay_gain_info,
*/
while (length >= 4) {
- const struct rva2_data *d = (const struct rva2_data *)data;
+ const Rva2Data &d = *(const Rva2Data *)data;
unsigned int peak_bytes = rva2_peak_bytes(d);
if (4 + peak_bytes > length)
break;
diff --git a/src/tag/TagRva2.hxx b/src/tag/TagRva2.hxx
index df559f472..510dd043e 100644
--- a/src/tag/TagRva2.hxx
+++ b/src/tag/TagRva2.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagSettings.c b/src/tag/TagSettings.c
index e0c577c2b..4582bd3c0 100644
--- a/src/tag/TagSettings.c
+++ b/src/tag/TagSettings.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagSettings.h b/src/tag/TagSettings.h
index 33f89d4be..cf91b52e1 100644
--- a/src/tag/TagSettings.h
+++ b/src/tag/TagSettings.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagString.cxx b/src/tag/TagString.cxx
index 4f07cd62a..85227de24 100644
--- a/src/tag/TagString.cxx
+++ b/src/tag/TagString.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagString.hxx b/src/tag/TagString.hxx
index eccc2aa47..f4cba9a40 100644
--- a/src/tag/TagString.hxx
+++ b/src/tag/TagString.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagTable.cxx b/src/tag/TagTable.cxx
index c6e1cff54..e2a22b642 100644
--- a/src/tag/TagTable.cxx
+++ b/src/tag/TagTable.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagTable.hxx b/src/tag/TagTable.hxx
index 095b4cbff..0d72cba99 100644
--- a/src/tag/TagTable.hxx
+++ b/src/tag/TagTable.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/TagType.h b/src/tag/TagType.h
index 0aa6b4a51..6f68d53d0 100644
--- a/src/tag/TagType.h
+++ b/src/tag/TagType.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/VorbisComment.cxx b/src/tag/VorbisComment.cxx
index 2dfc058d8..2c45470d4 100644
--- a/src/tag/VorbisComment.cxx
+++ b/src/tag/VorbisComment.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/VorbisComment.hxx b/src/tag/VorbisComment.hxx
index 1dd3371c8..e48e9b7a9 100644
--- a/src/tag/VorbisComment.hxx
+++ b/src/tag/VorbisComment.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify