LCOV - code coverage report
Current view: top level - src/playback/internal - soundprofilesrepository.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 54 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2022 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "soundprofilesrepository.h"
      24              : 
      25              : #include "log.h"
      26              : 
      27              : using namespace mu::playback;
      28              : using namespace muse;
      29              : using namespace muse::audio;
      30              : 
      31            0 : void SoundProfilesRepository::init()
      32              : {
      33            0 :     SoundProfile basicProfile;
      34            0 :     basicProfile.type = SoundProfileType::Basic;
      35            0 :     basicProfile.name = config()->basicSoundProfileName();
      36            0 :     m_profilesMap.emplace(basicProfile.name, std::move(basicProfile));
      37              : 
      38            0 :     SoundProfile museProfile;
      39            0 :     museProfile.type = SoundProfileType::Muse;
      40            0 :     museProfile.name = config()->museSoundsProfileName();
      41            0 :     m_profilesMap.emplace(museProfile.name, std::move(museProfile));
      42              : 
      43            0 :     if (playback()->isInited()) {
      44            0 :         refresh();
      45            0 :         return;
      46              :     }
      47              : 
      48            0 :     playback()->initedChanged().onReceive(this, [this](bool inited) {
      49            0 :         if (inited) {
      50            0 :             refresh();
      51            0 :             playback()->initedChanged().disconnect(this);
      52              :         }
      53            0 :     });
      54            0 : }
      55              : 
      56            0 : void SoundProfilesRepository::refresh()
      57              : {
      58            0 :     playback()->availableInputResources()
      59            0 :     .onResolve(this, [this](const AudioResourceMetaList& availableResources) {
      60            0 :         SoundProfile& basicProfile = m_profilesMap.at(config()->basicSoundProfileName());
      61            0 :         SoundProfile& museProfile = m_profilesMap.at(config()->museSoundsProfileName());
      62              : 
      63            0 :         for (const AudioResourceMeta& resource : availableResources) {
      64            0 :             auto setup = resource.attributes.find(u"playbackSetupData");
      65              : 
      66            0 :             if (setup == resource.attributes.cend()) {
      67            0 :                 continue;
      68              :             }
      69              : 
      70            0 :             if (isResourceType(resource, AudioResourceType::FluidSoundfont)) {
      71            0 :                 basicProfile.data.emplace(mpe::PlaybackSetupData::fromString(setup->second), resource);
      72              :             }
      73              : 
      74            0 :             if (isResourceType(resource, AudioResourceType::MuseSamplerSoundPack)) {
      75            0 :                 museProfile.data.emplace(mpe::PlaybackSetupData::fromString(setup->second), resource);
      76              :             }
      77              :         }
      78            0 :     })
      79            0 :     .onReject(this, [](const int errCode, const std::string& errText) {
      80            0 :         LOGE() << "Unable to resolve available output resources"
      81            0 :                << " , errCode:" << errCode
      82            0 :                << " , errText:" << errText;
      83            0 :     });
      84            0 : }
      85              : 
      86            0 : const SoundProfile& SoundProfilesRepository::profile(const SoundProfileName& name) const
      87              : {
      88            0 :     auto search = m_profilesMap.find(name);
      89            0 :     if (search == m_profilesMap.cend()) {
      90            0 :         static SoundProfile empty;
      91            0 :         return empty;
      92              :     }
      93              : 
      94            0 :     return search->second;
      95              : }
      96              : 
      97            0 : bool SoundProfilesRepository::containsProfile(const SoundProfileName& name) const
      98              : {
      99            0 :     return muse::contains(m_profilesMap, name);
     100              : }
     101              : 
     102            0 : const SoundProfilesMap& SoundProfilesRepository::availableProfiles() const
     103              : {
     104            0 :     return m_profilesMap;
     105              : }
     106              : 
     107            0 : void SoundProfilesRepository::addProfile(const SoundProfile& profile)
     108              : {
     109            0 :     m_profilesMap[profile.name] = profile;
     110            0 : }
     111              : 
     112            0 : void SoundProfilesRepository::removeProfile(const SoundProfileName& name)
     113              : {
     114            0 :     m_profilesMap.erase(name);
     115            0 : }
        

Generated by: LCOV version 2.0-1