SongUpdate: move tag_scan_fallback() to tag/Generic.cxx

This commit is contained in:
Max Kellermann 2016-02-22 18:00:49 +01:00
parent de568c84c2
commit 7623c1c5cb
7 changed files with 81 additions and 35 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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 */

34
src/tag/Generic.cxx Normal file
View File

@ -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);
}

34
src/tag/Generic.hxx Normal file
View File

@ -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

View File

@ -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;
}