From 904097b7b1518b98350124ee0e1b7e9e6fd980fe Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 7 Jul 2020 23:44:04 +0200 Subject: [PATCH] Add back option to use system taglib, add warning at the bottom --- CMakeLists.txt | 37 ++++++--- ext/libstrawberry-tagreader/tagreader.cpp | 98 ++++++++++++----------- ext/libstrawberry-tagreader/tagreader.h | 3 + src/config.h.in | 5 +- src/core/song.cpp | 2 + 5 files changed, 90 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5669543c..0162cb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,13 +193,28 @@ if(X11_FOUND) endif(X11_FOUND) # TAGLIB -set(TAGLIB_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/taglib/;${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/") -set(TAGLIB_LIBRARY_DIRS "") -set(TAGLIB_LIBRARIES tag) -add_subdirectory(3rdparty/utf8-cpp) -add_subdirectory(3rdparty/taglib) -set(HAVE_TAGLIB_DSFFILE ON) -add_definitions(-DTAGLIB_STATIC) +option(USE_SYSTEM_TAGLIB "Use system taglib" OFF) +if(USE_SYSTEM_TAGLIB) + pkg_check_modules(TAGLIB REQUIRED taglib>=1.11.1) + message(WARNING "Using system taglib library.") + find_path(HAVE_TAGLIB_DSFFILE_H taglib/dsffile.h) + find_path(HAVE_TAGLIB_DSDIFFFILE_H taglib/dsdifffile.h) + if(HAVE_TAGLIB_DSFFILE_H) + set(HAVE_TAGLIB_DSFFILE ON) + endif(HAVE_TAGLIB_DSFFILE_H) + if(HAVE_TAGLIB_DSDIFFFILE_H) + set(HAVE_TAGLIB_DSDIFFFILE ON) + endif(HAVE_TAGLIB_DSDIFFFILE_H) +else(USE_SYSTEM_TAGLIB) + set(TAGLIB_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/taglib/;${CMAKE_BINARY_DIR}/3rdparty/taglib/headers/") + set(TAGLIB_LIBRARY_DIRS "") + set(TAGLIB_LIBRARIES tag) + add_subdirectory(3rdparty/utf8-cpp) + add_subdirectory(3rdparty/taglib) + set(HAVE_TAGLIB_DSFFILE ON) + set(HAVE_TAGLIB_DSDIFFFILE ON) + add_definitions(-DTAGLIB_STATIC) +endif(USE_SYSTEM_TAGLIB) # SingleApplication add_subdirectory(3rdparty/singleapplication) @@ -388,9 +403,9 @@ option(BUILD_TAGLIB_TESTS "Build the test suite" OFF) if(BUILD_TESTS) add_subdirectory(tests) endif(BUILD_TESTS) -if(BUILD_TAGLIB_TESTS) +if(NOT USE_SYSTEM_TAGLIB AND BUILD_TAGLIB_TESTS) add_subdirectory(tests/taglib) -endif(BUILD_TAGLIB_TESTS) +endif(NOT USE_SYSTEM_TAGLIB AND BUILD_TAGLIB_TESTS) # Uninstall support configure_file( @@ -412,3 +427,7 @@ endif() if(NOT SQLITE3_FTS5 AND NOT CMAKE_CROSSCOMPILING) message(WARNING "sqlite3 must be enabled with FTS5. See: https://www.sqlite.org/fts5.html") endif() + +if(USE_SYSTEM_TAGLIB AND NOT TAGLIB_VERSION VERSION_GREATER 1.11.2) + message(WARNING "Using system taglib library. There is a critical bug in the current latest version of TagLib (1.11.1) that can corrupt Ogg files, make sure your systems version has been patched, see: https://github.com/taglib/taglib/issues/864, TagLib upstream is currently not maintained. Do not set USE_SYSTEM_TAGLIB unless you are prepared keep the TagLib in your system up to date with critical fixes.") +endif() diff --git a/ext/libstrawberry-tagreader/tagreader.cpp b/ext/libstrawberry-tagreader/tagreader.cpp index 1bf68383..24855f4e 100644 --- a/ext/libstrawberry-tagreader/tagreader.cpp +++ b/ext/libstrawberry-tagreader/tagreader.cpp @@ -25,51 +25,55 @@ #include #include -#include "taglib/taglib.h" -#include "taglib/fileref.h" -#include "taglib/tbytevector.h" -#include "taglib/tfile.h" -#include "taglib/tlist.h" -#include "taglib/tstring.h" -#include "taglib/tstringlist.h" -#include "taglib/audioproperties.h" -#include "taglib/attachedpictureframe.h" -#include "taglib/textidentificationframe.h" -#include "taglib/unsynchronizedlyricsframe.h" -#include "taglib/xiphcomment.h" -#include "taglib/commentsframe.h" -#include "taglib/tag.h" -#include "taglib/apetag.h" -#include "taglib/apeitem.h" -#include "taglib/apeproperties.h" -#include "taglib/id3v2tag.h" -#include "taglib/id3v2frame.h" -#include "taglib/flacfile.h" -#include "taglib/oggflacfile.h" -#include "taglib/flacproperties.h" -#include "taglib/flacpicture.h" -#include "taglib/vorbisfile.h" -#include "taglib/speexfile.h" -#include "taglib/wavfile.h" -#include "taglib/wavpackfile.h" -#include "taglib/wavpackproperties.h" -#include "taglib/aifffile.h" -#include "taglib/asffile.h" -#include "taglib/asftag.h" -#include "taglib/asfattribute.h" -#include "taglib/asfproperties.h" -#include "taglib/mp4file.h" -#include "taglib/mp4tag.h" -#include "taglib/mp4item.h" -#include "taglib/mp4coverart.h" -#include "taglib/mp4properties.h" -#include "taglib/mpcfile.h" -#include "taglib/mpegfile.h" -#include "taglib/opusfile.h" -#include "taglib/trueaudiofile.h" -#include "taglib/apefile.h" -#include "taglib/dsffile.h" -#include "taglib/dsdifffile.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_TAGLIB_DSFFILE +# include +#endif +#ifdef HAVE_TAGLIB_DSDIFFFILE +# include +#endif #include #include @@ -152,8 +156,12 @@ pb::tagreader::SongMetadata_FileType TagReader::GuessFileType(TagLib::FileRef *f if (dynamic_cast(fileref->file())) return pb::tagreader::SongMetadata_FileType_MPC; if (dynamic_cast(fileref->file())) return pb::tagreader::SongMetadata_FileType_TRUEAUDIO; if (dynamic_cast(fileref->file())) return pb::tagreader::SongMetadata_FileType_APE; +#ifdef HAVE_TAGLIB_DSFFILE if (dynamic_cast(fileref->file())) return pb::tagreader::SongMetadata_FileType_DSF; +#endif +#ifdef HAVE_TAGLIB_DSDIFFFILE if (dynamic_cast(fileref->file())) return pb::tagreader::SongMetadata_FileType_DSDIFF; +#endif return pb::tagreader::SongMetadata_FileType_UNKNOWN; diff --git a/ext/libstrawberry-tagreader/tagreader.h b/ext/libstrawberry-tagreader/tagreader.h index 78ad4b66..b35c73db 100644 --- a/ext/libstrawberry-tagreader/tagreader.h +++ b/ext/libstrawberry-tagreader/tagreader.h @@ -37,7 +37,10 @@ class QTextCodec; + +#ifndef USE_SYSTEM_TAGLIB using namespace Strawberry_TagLib; +#endif class FileRefFactory; diff --git a/src/config.h.in b/src/config.h.in index 2ee3b2da..5d51b62c 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -38,7 +38,6 @@ #cmakedefine HAVE_LIBPULSE #cmakedefine HAVE_SPARKLE #cmakedefine HAVE_CHROMAPRINT -#cmakedefine HAVE_TAGLIB_DSFFILE #cmakedefine HAVE_GLOBALSHORTCUTS #cmakedefine USE_INSTALL_PREFIX @@ -55,6 +54,10 @@ #cmakedefine HAVE_KEYSYMDEF_H #cmakedefine HAVE_XF86KEYSYM_H +#cmakedefine USE_SYSTEM_TAGLIB +#cmakedefine HAVE_TAGLIB_DSFFILE +#cmakedefine HAVE_TAGLIB_DSDIFFFILE + #cmakedefine USE_BUNDLE #define USE_BUNDLE_DIR "${USE_BUNDLE_DIR}" diff --git a/src/core/song.cpp b/src/core/song.cpp index 321e08b3..a09675f1 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -68,7 +68,9 @@ #include "covermanager/albumcoverloader.h" #include "tagreadermessages.pb.h" +#ifndef USE_SYSTEM_TAGLIB using namespace Strawberry_TagLib; +#endif const QStringList Song::kColumns = QStringList() << "title" << "album"