From 200c9b949d964dea034de7ea6ad9f6ce04a49643 Mon Sep 17 00:00:00 2001 From: Jakub Pyszczak Date: Fri, 27 Aug 2021 17:26:11 +0200 Subject: [PATCH] [EGD-7432] Tags fetcher Added tags fetcher as universal audio utility which can be used without bus overhead --- .../widgets/AlarmOptionsItem.cpp | 17 ++--- .../widgets/AlarmOptionsItem.hpp | 9 +-- .../ApplicationMusicPlayer.cpp | 2 +- .../application-music-player/CMakeLists.txt | 1 + .../models/SongsRepository.cpp | 14 ++-- .../models/SongsRepository.hpp | 12 +-- .../tests/MockSongsRepository.hpp | 2 +- .../tests/MockTagsFetcher.hpp | 2 +- .../tests/unittest_songrepository.cpp | 19 ++--- .../tests/unittest_songsmodel.cpp | 2 +- .../models/apps/SoundsModel.cpp | 7 +- module-audio/Audio/Audio.cpp | 11 --- module-audio/Audio/Audio.hpp | 2 - .../Audio/Operation/PlaybackOperation.cpp | 3 +- .../Audio/Operation/PlaybackOperation.hpp | 1 - module-audio/Audio/decoder/Decoder.cpp | 52 ++----------- module-audio/Audio/decoder/Decoder.hpp | 53 +------------ module-audio/Audio/decoder/decoderFLAC.cpp | 30 +------- module-audio/Audio/decoder/decoderFLAC.hpp | 5 +- module-audio/Audio/test/unittest_audio.cpp | 31 ++++---- module-audio/CMakeLists.txt | 3 + module-audio/README.md | 4 - module-audio/tags_fetcher/CMakeLists.txt | 20 +++++ module-audio/tags_fetcher/TagsFetcher.cpp | 75 +++++++++++++++++++ module-audio/tags_fetcher/TagsFetcher.hpp | 63 ++++++++++++++++ .../service-audio/AudioServiceAPI.cpp | 13 ---- .../service-audio/ServiceAudio.cpp | 12 --- .../include/service-audio/AudioMessage.hpp | 19 +---- .../include/service-audio/AudioServiceAPI.hpp | 8 -- .../include/service-audio/ServiceAudio.hpp | 1 - 30 files changed, 232 insertions(+), 261 deletions(-) create mode 100644 module-audio/tags_fetcher/CMakeLists.txt create mode 100644 module-audio/tags_fetcher/TagsFetcher.cpp create mode 100644 module-audio/tags_fetcher/TagsFetcher.hpp diff --git a/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp b/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp index 7068e34d47b0f79921df64765483e0fc3c6d19db..da1050a8f0bcc32b5ba6413c755ed381d1209098 100644 --- a/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp +++ b/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp @@ -242,7 +242,7 @@ namespace gui onLoadCallback = [&](std::shared_ptr alarm) { switch (itemName) { case AlarmOptionItemName::Sound: { - auto it = std::find_if(songsList.begin(), songsList.end(), [alarm](const audio::Tags &tag) { + auto it = std::find_if(songsList.begin(), songsList.end(), [alarm](const tags::fetcher::Tags &tag) { return tag.filePath == alarm->path.c_str(); }); if (it == songsList.end()) { @@ -308,22 +308,17 @@ namespace gui }; } - std::vector AlarmOptionsItem::getMusicFilesList() + std::vector AlarmOptionsItem::getMusicFilesList() { const auto musicFolder = (purefs::dir::getUserDiskPath() / "music").string(); - std::vector musicFiles; + std::vector musicFiles; LOG_INFO("Scanning music folder: %s", musicFolder.c_str()); for (const auto &ent : std::filesystem::directory_iterator(musicFolder)) { if (!ent.is_directory()) { const auto filePath = std::string(musicFolder) + "/" + ent.path().filename().c_str(); - auto fileTags = AudioServiceAPI::GetFileTags(application, filePath); - if (fileTags) { - musicFiles.push_back(*fileTags); - LOG_DEBUG("file: %s found", ent.path().filename().c_str()); - } - else { - LOG_ERROR("Not an audio file %s", ent.path().filename().c_str()); - } + auto fileTags = tags::fetcher::fetchTags(filePath); + musicFiles.push_back(fileTags); + LOG_DEBUG("file: %s found", ent.path().filename().c_str()); } } LOG_INFO("Total number of music files found: %u", static_cast(musicFiles.size())); diff --git a/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp b/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp index c10b9eb1e60e84f1b9e96dda8d8acd85940ce1d4..a9ed54b591bd37ae44213377dd3803f5a789dfb8 100644 --- a/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp +++ b/module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp @@ -9,7 +9,7 @@ #include #include #include -#include