LCOV - code coverage report
Current view: top level - muse/framework/audio/common - audiosanitizer.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 24 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) 2021 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              : #include "audiosanitizer.h"
      23              : 
      24              : #include <thread>
      25              : #include <atomic>
      26              : 
      27              : #include "containers.h"
      28              : 
      29              : using namespace muse::audio;
      30              : 
      31              : static std::thread::id s_as_mainThreadID;
      32              : static std::thread::id s_as_engineThreadID;
      33              : static std::set<std::thread::id> s_mixerThreadIdSet;
      34              : static std::atomic<engine::OperationType> s_operationType(engine::OperationType::Undefined);
      35              : 
      36            0 : void AudioSanitizer::setupMainThread()
      37              : {
      38            0 :     s_as_mainThreadID = std::this_thread::get_id();
      39            0 : }
      40              : 
      41            0 : std::thread::id AudioSanitizer::mainThread()
      42              : {
      43            0 :     return s_as_mainThreadID;
      44              : }
      45              : 
      46            0 : bool AudioSanitizer::isMainThread()
      47              : {
      48            0 :     return std::this_thread::get_id() == s_as_mainThreadID;
      49              : }
      50              : 
      51            0 : void AudioSanitizer::setupEngineThread()
      52              : {
      53            0 :     s_as_engineThreadID = std::this_thread::get_id();
      54            0 : }
      55              : 
      56            0 : void AudioSanitizer::setMixerThreads(const std::set<std::thread::id>& threadIdSet)
      57              : {
      58            0 :     s_mixerThreadIdSet = threadIdSet;
      59            0 : }
      60              : 
      61            0 : std::thread::id AudioSanitizer::engineThread()
      62              : {
      63            0 :     return s_as_engineThreadID;
      64              : }
      65              : 
      66            0 : bool AudioSanitizer::isEngineThread()
      67              : {
      68            0 :     std::thread::id id = std::this_thread::get_id();
      69              : 
      70            0 :     return id == s_as_engineThreadID || muse::contains(s_mixerThreadIdSet, id);
      71              : }
      72              : 
      73            0 : void AudioSanitizer::setOperationType(engine::OperationType type)
      74              : {
      75            0 :     s_operationType = type;
      76            0 : }
      77              : 
      78            0 : bool AudioSanitizer::isOperationExec()
      79              : {
      80            0 :     engine::OperationType type = s_operationType.load();
      81            0 :     return type != engine::OperationType::Undefined && type != engine::OperationType::NoOperation;
      82              : }
        

Generated by: LCOV version 2.0-1