LCOV - code coverage report
Current view: top level - muse/framework/audio - iaudiodriver.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 8 8
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) 2025 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              : #pragma once
      23              : 
      24              : #include <cstdint>
      25              : #include <string>
      26              : #include <vector>
      27              : #include <functional>
      28              : #include <memory>
      29              : 
      30              : #include "common/audioworkgroup.h"
      31              : #include "global/async/notification.h"
      32              : #include "global/logstream.h"
      33              : 
      34              : #include "audio/common/audiotypes.h"
      35              : 
      36              : namespace muse::audio {
      37              : class IAudioDriver
      38              : {
      39              : public:
      40           50 :     virtual ~IAudioDriver() = default;
      41              : 
      42              :     using Callback = std::function<void (uint8_t* stream, int len)>;
      43              : 
      44              :     struct Spec
      45              :     {
      46              :         AudioDeviceID deviceId;
      47              :         OutputSpec output;
      48              :         Callback callback;
      49           54 :         inline bool isValid() const { return output.isValid() && !deviceId.empty() && callback != nullptr; }
      50              :     };
      51              : 
      52              :     virtual void init() = 0;
      53              : 
      54              :     virtual std::string name() const = 0;
      55              : 
      56              :     virtual AudioDeviceID defaultDevice() const = 0;
      57           27 :     virtual AudioWorkGroup getAudioWorkGroup() const { return {}; }
      58           27 :     virtual async::Notification currentWorkgroupChanged() const { return {}; }
      59              : 
      60              :     virtual bool open(const Spec& spec, Spec* activeSpec) = 0;
      61              :     virtual void close() = 0;
      62              :     virtual bool isOpened() const = 0;
      63              : 
      64              :     virtual const Spec& activeSpec() const = 0;
      65              :     virtual async::Channel<Spec> activeSpecChanged() const = 0;
      66              : 
      67              :     virtual std::vector<samples_t> availableOutputDeviceBufferSizes() const = 0;
      68              :     virtual std::vector<sample_rate_t> availableOutputDeviceSampleRates() const = 0;
      69              :     virtual AudioDeviceList availableOutputDevices() const = 0;
      70              :     virtual async::Notification availableOutputDevicesChanged() const = 0;
      71              : };
      72              : using IAudioDriverPtr = std::shared_ptr<IAudioDriver>;
      73              : }
      74              : 
      75           73 : inline muse::logger::Stream& operator<<(muse::logger::Stream& s, const muse::audio::IAudioDriver::Spec& spec)
      76              : {
      77           73 :     s << "deviceId: " << spec.deviceId
      78           73 :       << ", " << spec.output;
      79           73 :     return s;
      80              : }
        

Generated by: LCOV version 2.0-1