From 47a12b220f24345d3410868f00ada1c5bf8e7d05 Mon Sep 17 00:00:00 2001 From: emeric Date: Wed, 25 Jun 2014 12:43:11 +0200 Subject: [PATCH] Covers. Minor bugfixes --- TODO | 6 +++--- configure.ac | 8 ++++---- cover/CoverArt.cpp | 4 ++++ cover/CoverArtGrabber.cpp | 6 ++++++ main/DatabaseRefreshService.cpp | 3 ++- remote/server/AudioCollectionRequestHandler.cpp | 11 +++++++++-- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 8b9be69d..1240118f 100644 --- a/TODO +++ b/TODO @@ -14,9 +14,9 @@ - Create a new type: "share", that handles every other types in a directory based share? - Group video in "video groups". Each video may has sub groups (current "Path" class) - Simplify database and remove the Path class -- Use limits for strings? -- Convert to UTF-8 in name strings +- Use size limits for strings? - Manage a global database revision number +- Process only files whose extensions are well known in audio/video world (avoid useless parsing/errors) [Audio] - ReleaseView/ArtistView/GenreView: -> Track count for this special category. Easier: add a special entry '' that contains everything? @@ -35,7 +35,7 @@ - Use Groups/SubGroups to organize videos (WTreeView?) [Remote API] -- Think about a remote API to get/retrieve media (i.e. for mobile apps) +- Use SSL based sockets [Layout] - Make it mobile browser compatible diff --git a/configure.ac b/configure.ac index 949d419e..3c772b10 100644 --- a/configure.ac +++ b/configure.ac @@ -52,10 +52,10 @@ AC_CHECK_LIB( [boost_locale], , [AC_MSG_ERROR([libboost_locale not found!])]) -#AC_CHECK_LIB( [boost_thread], -# [main], -# , -# [AC_MSG_ERROR([libboost_thread not found!])]) +AC_CHECK_LIB( [boost_thread], + [main], + , + [AC_MSG_ERROR([libboost_thread not found!])]) #AC_CHECK_LIB( [boost_date_time], # [main], diff --git a/cover/CoverArt.cpp b/cover/CoverArt.cpp index 2fabb095..353b1b47 100644 --- a/cover/CoverArt.cpp +++ b/cover/CoverArt.cpp @@ -13,6 +13,10 @@ bool CoverArt::scale(std::size_t size) { bool res = false; + + if (!size) + return false; + try { boost::gil::rgb8_image_t source; diff --git a/cover/CoverArtGrabber.cpp b/cover/CoverArtGrabber.cpp index cb664601..c5be36fd 100644 --- a/cover/CoverArtGrabber.cpp +++ b/cover/CoverArtGrabber.cpp @@ -39,6 +39,9 @@ Grabber::getFromTrack(Track::pointer track) { std::vector res; + if (!track) + return std::vector(); + try { Av::InputFormatContext input(track->getPath()); @@ -56,6 +59,9 @@ Grabber::getFromTrack(Track::pointer track) std::vector Grabber::getFromRelease(Release::pointer release) { + if (!release) + return std::vector(); + // TODO // Check if there is an image file in the directory of the release // For now, just get the cover art from the first track of the release diff --git a/main/DatabaseRefreshService.cpp b/main/DatabaseRefreshService.cpp index b7d95533..4403197b 100644 --- a/main/DatabaseRefreshService.cpp +++ b/main/DatabaseRefreshService.cpp @@ -1,3 +1,4 @@ +#include #include "DatabaseRefreshService.hpp" @@ -12,7 +13,7 @@ DatabaseRefreshService::DatabaseRefreshService(boost::asio::io_service& ioServic _database.watchDirectory( WatchedDirectory("/storage/common/Media/Video", WatchedDirectory::Video) ); // TODO launch thread - // boost::thread refreshThread(boost::bind(&Database::refresh, &database)); + boost::thread refreshThread(boost::bind(&Database::refresh, &_database)); } void diff --git a/remote/server/AudioCollectionRequestHandler.cpp b/remote/server/AudioCollectionRequestHandler.cpp index be8b60f5..8ed28fb6 100644 --- a/remote/server/AudioCollectionRequestHandler.cpp +++ b/remote/server/AudioCollectionRequestHandler.cpp @@ -2,7 +2,6 @@ #include - #include #include "AudioCollectionRequestHandler.hpp" @@ -275,7 +274,15 @@ AudioCollectionRequestHandler::processGetCoverArt(const AudioCollectionRequest:: AudioCollectionResponse_CoverArt* cover_art = response.add_cover_art(); if (request.has_size()) - coverArt.scale(request.size()); + { + std::size_t size = request.size(); + if (size > _maxCoverArtSize || size == 0) + size = _maxCoverArtSize; + if (size < _minCoverArtSize) + size = _minCoverArtSize; + + coverArt.scale(size); + } cover_art->set_mime_type(coverArt.getMimeType()); cover_art->set_data( std::string( coverArt.getData().begin(), coverArt.getData().end()) );