LCOV - code coverage report
Current view: top level - muse/framework/musesampler - musesamplermodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 45 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-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 "musesamplermodule.h"
      24              : 
      25              : #include "modularity/ioc.h"
      26              : 
      27              : #include "rcommand/icommandsregister.h"
      28              : #include "rcommand/icommandsstate.h"
      29              : 
      30              : #include "audio/engine/isynthresolver.h"
      31              : 
      32              : #include "imusesamplerinfo.h"
      33              : #include "internal/musesamplerconfiguration.h"
      34              : #include "internal/musesamplerresolver.h"
      35              : #include "internal/musesampleractioncontroller.h"
      36              : #include "internal/musesamplercommandsregister.h"
      37              : #include "internal/musesamplercommandsstate.h"
      38              : 
      39              : #include "diagnostics/idiagnosticspathsregister.h"
      40              : 
      41              : using namespace muse;
      42              : using namespace muse::audio;
      43              : using namespace muse::modularity;
      44              : using namespace muse::musesampler;
      45              : 
      46              : static const std::string mname("musesampler");
      47              : 
      48            0 : std::string MuseSamplerModule::moduleName() const
      49              : {
      50            0 :     return mname;
      51              : }
      52              : 
      53            0 : void MuseSamplerModule::registerExports()
      54              : {
      55            0 :     m_configuration = std::make_shared<MuseSamplerConfiguration>(globalCtx());
      56            0 :     m_resolver = std::make_shared<MuseSamplerResolver>();
      57              : 
      58            0 :     globalIoc()->registerExport<IMuseSamplerConfiguration>(mname, m_configuration);
      59            0 :     globalIoc()->registerExport<IMuseSamplerInfo>(mname, m_resolver);
      60            0 : }
      61              : 
      62            0 : void MuseSamplerModule::resolveImports()
      63              : {
      64            0 :     auto synthResolver = globalIoc()->resolve<synth::ISynthResolver>(mname);
      65              : 
      66            0 :     if (synthResolver) {
      67            0 :         synthResolver->registerResolver(AudioSourceType::MuseSampler, m_resolver);
      68              :     }
      69              : 
      70            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
      71            0 :     if (cr) {
      72            0 :         cr->reg(std::make_shared<MuseSamplerCommandsRegister>());
      73              :     }
      74            0 : }
      75              : 
      76            0 : void MuseSamplerModule::onInit(const IApplication::RunMode&)
      77              : {
      78            0 :     m_configuration->init();
      79            0 :     m_resolver->init();
      80              : 
      81            0 :     auto pr = globalIoc()->resolve<muse::diagnostics::IDiagnosticsPathsRegister>(mname);
      82            0 :     if (pr) {
      83            0 :         pr->reg("musesampler", m_configuration->libraryPath());
      84              :     }
      85            0 : }
      86              : 
      87            0 : void MuseSamplerModule::onDeinit()
      88              : {
      89            0 :     m_resolver->deinit();
      90            0 : }
      91              : 
      92            0 : IContextSetup* MuseSamplerModule::newContext(const muse::modularity::ContextPtr& ctx) const
      93              : {
      94            0 :     return new MuseSamplerContext(ctx);
      95              : }
      96              : 
      97            0 : void MuseSamplerContext::registerExports()
      98              : {
      99            0 :     m_actionController = std::make_shared<MuseSamplerActionController>(iocContext());
     100            0 : }
     101              : 
     102            0 : void MuseSamplerContext::resolveImports()
     103              : {
     104            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
     105            0 :     if (cs) {
     106            0 :         cs->reg(std::make_shared<MuseSamplerCommandsState>(iocContext()));
     107              :     }
     108            0 : }
     109              : 
     110            0 : void MuseSamplerContext::onInit(const IApplication::RunMode&)
     111              : {
     112            0 :     auto iresolver = globalIoc()->resolve<IMuseSamplerInfo>(mname);
     113            0 :     IF_ASSERT_FAILED(iresolver) {
     114            0 :         return;
     115              :     }
     116              : 
     117            0 :     auto resolver = std::dynamic_pointer_cast<MuseSamplerResolver>(iresolver);
     118            0 :     IF_ASSERT_FAILED(resolver) {
     119            0 :         return;
     120              :     }
     121              : 
     122            0 :     m_actionController->init(resolver);
     123            0 : }
        

Generated by: LCOV version 2.0-1