summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-22 18:00:49 +0100
committerMax Kellermann <max@duempel.org>2016-02-22 18:00:49 +0100
commit7623c1c5cba95f24f2fb530d9796eceb9a95b710 (patch)
treee66472158e5740fa2868f2c59aa6c818a32f1110
parentde568c84c267f4b33afd6dac10b6de15a8a38a69 (diff)
SongUpdate: move tag_scan_fallback() to tag/Generic.cxx
-rw-r--r--Makefile.am1
-rw-r--r--src/SongUpdate.cxx21
-rw-r--r--src/command/FileCommands.cxx6
-rw-r--r--src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx10
-rw-r--r--src/tag/Generic.cxx34
-rw-r--r--src/tag/Generic.hxx34
-rw-r--r--test/read_tags.cxx10
7 files changed, 81 insertions, 35 deletions
diff --git a/Makefile.am b/Makefile.am
index f94ef3c8c..2a44e4437 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -862,6 +862,7 @@ libtag_a_SOURCES =\
src/tag/VorbisComment.cxx src/tag/VorbisComment.hxx \
src/tag/ReplayGain.cxx src/tag/ReplayGain.hxx \
src/tag/MixRamp.cxx src/tag/MixRamp.hxx \
+ src/tag/Generic.cxx src/tag/Generic.hxx \
src/tag/ApeLoader.cxx src/tag/ApeLoader.hxx \
src/tag/ApeReplayGain.cxx src/tag/ApeReplayGain.hxx \
src/tag/ApeTag.cxx src/tag/ApeTag.hxx
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index ae152b8dc..5b1141a40 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -32,8 +32,7 @@
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagHandler.hxx"
-#include "tag/TagId3.hxx"
-#include "tag/ApeTag.hxx"
+#include "tag/Generic.hxx"
#include "TagFile.hxx"
#include "TagStream.hxx"
@@ -73,17 +72,6 @@ Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
#endif
-/**
- * Attempts to load APE or ID3 tags from the specified file.
- */
-static bool
-tag_scan_fallback(Path path,
- const TagHandler *handler, void *handler_ctx)
-{
- return tag_ape_scan2(path, handler, handler_ctx) ||
- tag_id3_scan(path, handler, handler_ctx);
-}
-
#ifdef ENABLE_DATABASE
bool
@@ -112,8 +100,8 @@ Song::UpdateFile(Storage &storage)
return false;
if (tag_builder.IsEmpty())
- tag_scan_fallback(path_fs, &full_tag_handler,
- &tag_builder);
+ ScanGenericTags(path_fs, full_tag_handler,
+ &tag_builder);
}
mtime = info.mtime;
@@ -165,8 +153,7 @@ DetachedSong::LoadFile(Path path)
return false;
if (tag_builder.IsEmpty())
- tag_scan_fallback(path, &full_tag_handler,
- &tag_builder);
+ ScanGenericTags(path, full_tag_handler, &tag_builder);
mtime = fi.GetModificationTime();
tag_builder.Commit(tag);
diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx
index 6f342b570..374f89fc1 100644
--- a/src/command/FileCommands.cxx
+++ b/src/command/FileCommands.cxx
@@ -31,8 +31,7 @@
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "tag/TagHandler.hxx"
-#include "tag/ApeTag.hxx"
-#include "tag/TagId3.hxx"
+#include "tag/Generic.hxx"
#include "TagStream.hxx"
#include "TagFile.hxx"
#include "storage/StorageInterface.hxx"
@@ -174,8 +173,7 @@ read_file_comments(Response &r, const Path path_fs)
return CommandResult::ERROR;
}
- tag_ape_scan2(path_fs, &print_comment_handler, &r);
- tag_id3_scan(path_fs, &print_comment_handler, &r);
+ ScanGenericTags(path_fs, print_comment_handler, &r);
return CommandResult::OK;
diff --git a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
index 2dd615793..10b5cbf49 100644
--- a/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
+++ b/src/playlist/plugins/EmbeddedCuePlaylistPlugin.cxx
@@ -29,8 +29,7 @@
#include "../SongEnumerator.hxx"
#include "../cue/CueParser.hxx"
#include "tag/TagHandler.hxx"
-#include "tag/TagId3.hxx"
-#include "tag/ApeTag.hxx"
+#include "tag/Generic.hxx"
#include "DetachedSong.hxx"
#include "TagFile.hxx"
#include "fs/Traits.hxx"
@@ -104,11 +103,8 @@ embcue_playlist_open_uri(const char *uri,
const auto playlist = new EmbeddedCuePlaylist();
tag_file_scan(path_fs, embcue_tag_handler, playlist);
- if (playlist->cuesheet.empty()) {
- tag_ape_scan2(path_fs, &embcue_tag_handler, playlist);
- if (playlist->cuesheet.empty())
- tag_id3_scan(path_fs, &embcue_tag_handler, playlist);
- }
+ if (playlist->cuesheet.empty())
+ ScanGenericTags(path_fs, embcue_tag_handler, playlist);
if (playlist->cuesheet.empty()) {
/* no "CUESHEET" tag found */
diff --git a/src/tag/Generic.cxx b/src/tag/Generic.cxx
new file mode 100644
index 000000000..0c2ce46f0
--- /dev/null
+++ b/src/tag/Generic.cxx
@@ -0,0 +1,34 @@
+/*
+ * 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 "Generic.hxx"
+#include "TagId3.hxx"
+#include "ApeTag.hxx"
+#include "fs/Path.hxx"
+
+/**
+ * Attempts to scan APE or ID3 tags from the specified file.
+ */
+bool
+ScanGenericTags(Path path, const TagHandler &handler, void *ctx)
+{
+ return tag_ape_scan2(path, &handler, ctx) ||
+ tag_id3_scan(path, &handler, ctx);
+}
diff --git a/src/tag/Generic.hxx b/src/tag/Generic.hxx
new file mode 100644
index 000000000..5bd9cc7cb
--- /dev/null
+++ b/src/tag/Generic.hxx
@@ -0,0 +1,34 @@
+/*
+ * 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_GENERIC_HXX
+#define MPD_TAG_GENERIC_HXX
+
+#include "check.h"
+
+struct TagHandler;
+class Path;
+
+/**
+ * Attempts to scan APE or ID3 tags from the specified file.
+ */
+bool
+ScanGenericTags(Path path, const TagHandler &handler, void *ctx);
+
+#endif
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index 6685d7f3b..21f95db84 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -25,8 +25,7 @@
#include "input/InputStream.hxx"
#include "AudioFormat.hxx"
#include "tag/TagHandler.hxx"
-#include "tag/TagId3.hxx"
-#include "tag/ApeTag.hxx"
+#include "tag/Generic.hxx"
#include "util/Error.hxx"
#include "fs/Path.hxx"
#include "thread/Cond.hxx"
@@ -126,11 +125,8 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (empty) {
- tag_ape_scan2(path, &print_handler, NULL);
- if (empty)
- tag_id3_scan(path, &print_handler, NULL);
- }
+ if (empty)
+ ScanGenericTags(path, print_handler, nullptr);
return 0;
}