diff --git a/.travis.yml b/.travis.yml index f2f798b8..be9b1c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: - gcc before_install: - eval "${MATRIX_EVAL}" -- sudo apt-get install build-essential cmake libboost-all-dev libconfig++-dev libavcodec-dev libavutil-dev libavformat-dev ffmpeg libmagick++-dev libpstreams-dev libconfig++-dev libpstreams-dev libtag1-dev +- sudo apt-get install build-essential cmake libboost-all-dev libconfig++-dev libavcodec-dev libavutil-dev libavformat-dev ffmpeg libgraphicsmagick++1-dev libpstreams-dev libconfig++-dev libpstreams-dev libtag1-dev - git clone https://github.com/emweb/wt.git wt - pushd wt; - git checkout 4.1.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 516595ee..804bf495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) include(CTest) find_package(PkgConfig) -pkg_check_modules(IMAGEMAGICKXX REQUIRED ImageMagick++) +pkg_check_modules(GRAPHICSMAGICKXX REQUIRED GraphicsMagick++) add_subdirectory(src) diff --git a/README.md b/README.md index 25b903a4..0a800149 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ __Notes__: * a C++17 compiler is needed * ffmpeg version 4 minimum is required ```sh -apt-get install g++ cmake libboost-system-dev libavutil-dev libavformat-dev libmagick++-dev libconfig++-dev libpstreams-dev ffmpeg libtag1-dev +apt-get install g++ cmake libboost-system-dev libavutil-dev libavformat-dev libgraphicsmagick++1-dev libconfig++-dev libpstreams-dev ffmpeg libtag1-dev ``` You also need _Wt4_, which is not packaged yet on _Debian_. See [installation instructions](https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html).
@@ -208,6 +208,6 @@ To connect to _LMS_, just open your favorite browser and go to http://localhost: * Wt (http://www.webtoolkit.eu/) * bootstrap3 (http://getbootstrap.com/) * ffmpeg project (https://ffmpeg.org/) -* Magick++ (http://www.imagemagick.org/Magick++/) +* GraphicsMagick++ (http://www.graphicsmagick.org/) * MetaBrainz (https://metabrainz.org/) * Bootstrap Notify: https://github.com/mouse0270/bootstrap-notify diff --git a/docker/Dockerfile b/docker/Dockerfile index 4ac83cd4..6e404a0e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /tmp/workdir ARG MAKEFLAGS="-j2" ARG FFMPEG_VERSION=4.1.4 ARG WT_VERSION=4.2.0 -ARG IMAGEMAGICK6_VERSION=6.9.10-71 +ARG GRAPHICSMAGICK_VERSION=1.3.35 ARG PSTREAMS_VERSION=1.0.1 ARG LMS_VERSION=v3.6.3 @@ -24,6 +24,7 @@ ARG BUILD_PACKAGES=" \ make \ libjpeg-turbo-dev \ openjpeg-dev \ + jasper-dev \ libpng-dev \ tiff-dev \ nasm \ @@ -95,50 +96,42 @@ RUN \ make && \ make install -# ImageMagick +# GraphicsMagick++ RUN \ - DIR=/tmp/imagemagick && mkdir -p ${DIR} && cd ${DIR} && \ - curl -sLO https://github.com/ImageMagick/ImageMagick6/archive/${IMAGEMAGICK6_VERSION}.tar.gz && \ - tar -x --strip-components=1 -f ${IMAGEMAGICK6_VERSION}.tar.gz + DIR=/tmp/graphicsmagick && mkdir -p ${DIR} && cd ${DIR} && \ + curl -sL ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-${GRAPHICSMAGICK_VERSION}.tar.gz -o ${GRAPHICSMAGICK_VERSION}.tar.gz && \ + tar -x --strip-components=1 -f ${GRAPHICSMAGICK_VERSION}.tar.gz RUN \ - DIR=/tmp/imagemagick && mkdir -p ${DIR} && cd ${DIR} && \ + DIR=/tmp/graphicsmagick && mkdir -p ${DIR} && cd ${DIR} && \ ./configure \ --prefix=${PREFIX} \ --enable-shared=yes \ - --disable-static \ - --disable-docs \ - --with-magick-plus-plus \ - --without-zstd \ - --without-dps \ - --without-autotrace \ - --without-dps \ - --without-fftw \ - --without-flif \ - --without-fpx \ - --without-djvu \ - --without-fontconfig \ - --without-freetype \ - --without-raqm \ - --without-gslib \ - --without-gvc \ - --without-heic \ - --without-jbig \ - --with-jpeg \ - --without-jxl \ - --without-lcms \ - --with-openjp2 \ - --without-lqr \ - --with-lzma \ - --without-openexr \ - --without-pango \ - --with-png \ - --without-raw \ - --without-rsvg \ - --with-tiff \ - --without-webp \ - --without-wmf \ - --without-xml && \ + --enable-static=no \ + --with-quantum-depth=8 \ + --with-modules=no \ + --with-frozenpaths=no \ + --with-magick-plus-plus=yes \ + --with-perl=no \ + --with-bzlib=no \ + --with-dps=no \ + --with-fpx=no \ + --with-jbig=no \ + --with-webp=no \ + --with-jp2=yes \ + --with-jpeg=yes \ + --with-lcms2=no \ + --with-lzma=no \ + --with-png=yes \ + --with-tiff=yes \ + --with-trio=no \ + --with-ttf=no \ + --with-tcmalloc=no \ + --with-wmf=no \ + --with-xml=no \ + --with-zlib=yes \ + --with-zstd=no \ + --with-x=no && \ make && \ make install && \ make distclean @@ -178,7 +171,8 @@ RUN \ done && \ cp -r ${PREFIX}/lib /tmp/fakeroot/lib && \ cp -r ${PREFIX}/share /tmp/fakeroot/share && \ - LD_LIBRARY_PATH=/tmp/fakeroot/lib /tmp/fakeroot/bin/ffmpeg -buildconf + rm -rf /tmp/fakeroot/share/doc && \ + rm -rf /tmp/fakeroot/share/man ## Release Stage FROM alpine:3.10 AS release @@ -188,6 +182,7 @@ ARG RUNTIME_PACKAGES=" \ openssl \ libjpeg-turbo \ openjpeg \ + jasper-libs \ libpng \ tiff \ libogg \ diff --git a/src/libs/cover/CMakeLists.txt b/src/libs/cover/CMakeLists.txt index 62eb5d43..cffb40b5 100644 --- a/src/libs/cover/CMakeLists.txt +++ b/src/libs/cover/CMakeLists.txt @@ -10,17 +10,17 @@ target_include_directories(lmscover INTERFACE target_include_directories(lmscover PRIVATE include - ${IMAGEMAGICKXX_INCLUDE_DIRS} + ${GRAPHICSMAGICKXX_INCLUDE_DIRS} ) target_compile_options(lmscover PRIVATE - ${IMAGEMAGICKXX_CFLAGS_OTHER} + ${GRAPHICSMAGICKXX_CFLAGS_OTHER} ) target_link_libraries(lmscover PRIVATE lmsav lmsdatabase - ${IMAGEMAGICKXX_LIBRARIES} + ${GRAPHICSMAGICKXX_LIBRARIES} ) install(TARGETS lmscover DESTINATION lib) diff --git a/src/libs/cover/impl/CoverArtGrabber.cpp b/src/libs/cover/impl/CoverArtGrabber.cpp index 110b80d1..38781cbc 100644 --- a/src/libs/cover/impl/CoverArtGrabber.cpp +++ b/src/libs/cover/impl/CoverArtGrabber.cpp @@ -49,15 +49,13 @@ Grabber::Grabber(const std::filesystem::path& execPath) init(execPath); } -Grabber::~Grabber() -{ - deinit(); -} - void Grabber::setDefaultCover(const std::filesystem::path& p) { - if (!_defaultCover.load(p)) + std::unique_lock lock {_mutex}; + + _defaultCover = std::make_unique(); + if (!_defaultCover->load(p)) throw LmsException("Cannot read default cover file '" + p.string() + "'"); } @@ -65,12 +63,12 @@ Image Grabber::getDefaultCover(std::size_t size) { LMS_LOG(COVER, DEBUG) << "Getting a default cover using size = " << size; - std::unique_lock lock(_mutex); + std::unique_lock lock {_mutex}; auto it = _defaultCovers.find(size); if (it == _defaultCovers.end()) { - Image cover = _defaultCover; + Image cover = *_defaultCover; LMS_LOG(COVER, DEBUG) << "default cover size = " << cover.getSize().width << " x " << cover.getSize().height; diff --git a/src/libs/cover/impl/CoverArtGrabber.hpp b/src/libs/cover/impl/CoverArtGrabber.hpp index bc921355..df932315 100644 --- a/src/libs/cover/impl/CoverArtGrabber.hpp +++ b/src/libs/cover/impl/CoverArtGrabber.hpp @@ -41,7 +41,6 @@ namespace CoverArt { public: Grabber(const std::filesystem::path& execPath); - ~Grabber(); Grabber(const Grabber&) = delete; Grabber& operator=(const Grabber&) = delete; @@ -63,9 +62,8 @@ namespace CoverArt std::optional getFromDirectory(const std::filesystem::path& path) const; Image getDefaultCover(std::size_t size); - Image _defaultCover; - std::mutex _mutex; + std::unique_ptr _defaultCover; std::map _defaultCovers; static inline const std::vector _fileExtensions {".jpg", ".jpeg", ".png", ".bmp"}; // TODO parametrize diff --git a/src/libs/cover/impl/Image.cpp b/src/libs/cover/impl/Image.cpp index a39c0061..f05fcc73 100644 --- a/src/libs/cover/impl/Image.cpp +++ b/src/libs/cover/impl/Image.cpp @@ -29,12 +29,6 @@ init(const std::filesystem::path& path) Magick::InitializeMagick(path.string().c_str()); } -void -deinit() -{ - MagickCore::MagickCoreTerminus(); -} - static std::string formatToMagick(Format format) diff --git a/src/libs/cover/impl/Image.hpp b/src/libs/cover/impl/Image.hpp index 6932825f..7abcb37c 100644 --- a/src/libs/cover/impl/Image.hpp +++ b/src/libs/cover/impl/Image.hpp @@ -30,7 +30,6 @@ namespace CoverArt { void init(const std::filesystem::path& path); - void deinit(); class Image {