• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 30826105710

03 Aug 2026 03:08PM UTC coverage: 15.264%. Remained the same
30826105710

Pull #1975

github

web-flow
Merge a8c35e79e into 192676568
Pull Request #1975: audio: add a native ASIO backend on Windows

1 of 15 new or added lines in 3 files covered. (6.67%)

30464 of 199583 relevant lines covered (15.26%)

1075.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.65
/src/plugins/score-plugin-audio/score_plugin_audio.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3

4
#include "score_plugin_audio.hpp"
5

6
#include <Audio/ALSAInterface.hpp>
7
#include <Audio/ALSAMiniAudioInterface.hpp>
8
#include <Audio/ALSAPortAudioInterface.hpp>
9
#include <Audio/ASIOInterface.hpp>
10
#include <Audio/ASIOPortAudioInterface.hpp>
11
#include <Audio/AudioApplicationPlugin.hpp>
12
#include <Audio/AudioDevice.hpp>
13
#include <Audio/AudioPreviewExecutor.hpp>
14
#include <Audio/CoreAudioInterface.hpp>
15
#include <Audio/DummyInterface.hpp>
16
#include <Audio/GenericPortAudioInterface.hpp>
17
#include <Audio/JackInterface.hpp>
18
#include <Audio/MMEPortAudioInterface.hpp>
19
#include <Audio/PipeWireInterface.hpp>
20
#include <Audio/PortAudioInterface.hpp>
21
#include <Audio/SDLInterface.hpp>
22
#include <Audio/Settings/Factory.hpp>
23
#include <Audio/WASAPIPortAudioInterface.hpp>
24
#include <Audio/WASAPIMiniAudioInterface.hpp>
25
#include <Audio/WASMMiniAudioInterface.hpp>
26
#include <Audio/WDMKSPortAudioInterface.hpp>
27

28
#include <score/plugins/FactorySetup.hpp>
29
#include <score/plugins/InterfaceList.hpp>
30
#include <score/plugins/StringFactoryKey.hpp>
31
#include <score/plugins/UuidKeySerialization.hpp>
32

33
#include <wobjectimpl.h>
34

35
#include <ossia-config.hpp>
36

37
#if OSSIA_AUDIO_PORTAUDIO && defined(__linux__) && __has_include(<alsa/asoundlib.h>)
38
#include <alsa/asoundlib.h>
39
static void asound_error(
×
40
    const char* file, int line, const char* function, int err, const char* fmt, ...)
41
{
42
}
×
43
#endif
44

45
score_plugin_audio::score_plugin_audio()
128✔
46
{
128✔
47
  qRegisterMetaType<Audio::AudioFactory::ConcreteKey>(
32✔
48
      "Audio::AudioFactory::ConcreteKey");
49
  qRegisterMetaType<Audio::Settings::ExternalTransport>(
32✔
50
      "Audio::Settings::ExternalTransport");
51

52
  auto only_dummy_audio = qEnvironmentVariableIntValue("SCORE_ONLY_DUMMY_AUDIO") > 0;
32✔
53

54
  if(!only_dummy_audio)
32✔
55
  {
56
#if OSSIA_AUDIO_JACK
57
    jack_set_error_function(
32✔
58
        [](const char* str) { std::cerr << "JACK ERROR: " << str << std::endl; });
32✔
59
    jack_set_info_function([](const char* str) {
32✔
60
      // std::cerr << "JACK INFO: " << str << std::endl;
61
    });
×
62
#endif
63
#if OSSIA_AUDIO_PORTAUDIO && defined(__linux__) && __has_include(<alsa/asoundlib.h>)
64
    auto asound = dlopen("libasound.so.2", RTLD_LAZY | RTLD_LOCAL);
32✔
65
    auto sym = (decltype(snd_lib_error_set_handler)*)dlsym(
32✔
66
        asound, "snd_lib_error_set_handler");
32✔
67
    sym(asound_error);
32✔
68
#endif
69
  }
32✔
70
}
32✔
71

72
score_plugin_audio::~score_plugin_audio() { }
32✔
73

74
score::GUIApplicationPlugin*
75
score_plugin_audio::make_guiApplicationPlugin(const score::GUIApplicationContext& app)
39✔
76
{
77
  return new Audio::ApplicationPlugin{app};
39✔
78
}
×
79

80
std::vector<std::unique_ptr<score::InterfaceListBase>>
81
score_plugin_audio::factoryFamilies()
39✔
82
{
83
  return make_ptr_vector<score::InterfaceListBase, Audio::AudioFactoryList>();
39✔
84
}
85

86
template <typename... Args>
87
auto add_factories(
2,886✔
88
    std::vector<score::InterfaceBase*>& vec, const auto& ctx,
89
    const score::InterfaceKey& key) noexcept
90
{
91
  ossia::for_each_type_if_tagged<Args...>([&](auto t) {
8,541✔
92
    using fw_t = typename decltype(t)::type;
93
    return fw_t{}(ctx, key, vec);
5,655✔
94
  });
95
}
2,886✔
96

97
std::vector<score::InterfaceBase*> score_plugin_audio::factories(
1,443✔
98
    const score::ApplicationContext& ctx, const score::InterfaceKey& key) const
99
{
100
  std::vector<score::InterfaceBase*> vec;
1,443✔
101
  {
102
    // Common stuff
103
    add_factories<
1,443✔
104
        FW<Device::ProtocolFactory
105
#if defined(OSSIA_PROTOCOL_AUDIO)
106
           ,
107
           Dataflow::AudioProtocolFactory
108
#endif
109
           >,
110
        FW<score::SettingsDelegateFactory, Audio::Settings::Factory>,
111
        FW<Execution::ExecutionAction, Audio::AudioPreviewExecutor>>(vec, ctx, key);
1,443✔
112
  }
113

114
  using namespace Audio;
115
  auto only_dummy_audio = qEnvironmentVariableIntValue("SCORE_ONLY_DUMMY_AUDIO") > 0;
1,443✔
116
  auto forced_backend = qEnvironmentVariable("SCORE_AUDIO_BACKEND").toLower();
1,443✔
117
  if(only_dummy_audio)
1,443✔
118
  {
119
    add_factories<FW<Audio::AudioFactory, Audio::DummyFactory>>(vec, ctx, key);
×
120
    return vec;
×
121
  }
122
  else if(!forced_backend.isEmpty())
1,443✔
123
  {
124
    if(forced_backend == "sdl")
1,443✔
125
    {
126
#if defined(OSSIA_AUDIO_SDL)
127
      add_factories<FW<Audio::AudioFactory, Audio::SDLFactory>>(vec, ctx, key);
×
128
      return vec;
×
129
#endif
130
    }
131
    else if(forced_backend == "jack")
1,443✔
132
    {
133
#if defined(OSSIA_AUDIO_JACK)
134
      add_factories<FW<Audio::AudioFactory, Audio::JackFactory>>(vec, ctx, key);
×
135
      return vec;
×
136
#endif
137
    }
138
    else if(forced_backend == "pipewire")
1,443✔
139
    {
140
#if defined(OSSIA_AUDIO_PIPEWIRE)
141
      add_factories<FW<Audio::AudioFactory, Audio::PipeWireAudioFactory>>(vec, ctx, key);
×
142
      return vec;
×
143
#endif
144
    }
145
    else if(forced_backend == "alsa")
1,443✔
146
    {
147
#if OSSIA_AUDIO_ALSA
148
      add_factories<FW<Audio::AudioFactory, Audio::ALSAFactory>>(vec, ctx, key);
×
149
      return vec;
×
150
#endif
151
    }
152
    else if(forced_backend == "alsa_miniaudio")
1,443✔
153
    {
154
#if defined(__linux__) && defined(OSSIA_AUDIO_MINIAUDIO)
155
      add_factories<FW<Audio::AudioFactory, Audio::ALSAMiniAudioFactory>>(vec, ctx, key);
×
156
      return vec;
×
157
#endif
158
    }
159
    else if(forced_backend == "wasapi_miniaudio")
1,443✔
160
    {
161
#if defined(_WIN32) && defined(OSSIA_AUDIO_MINIAUDIO)
162
      add_factories<FW<Audio::AudioFactory, Audio::WASAPIMiniAudioFactory>>(
163
          vec, ctx, key);
164
      return vec;
165
#endif
NEW
166
    }
×
167
    else if(forced_backend == "asio")
1,443✔
168
    {
169
#if defined(OSSIA_AUDIO_ASIO)
170
      add_factories<FW<Audio::AudioFactory, Audio::NativeASIOFactory>>(vec, ctx, key);
171
      return vec;
172
#endif
173
    }
×
174
    else if(forced_backend == "dummy")
1,443✔
175
    {
176
      add_factories<FW<Audio::AudioFactory, Audio::DummyFactory>>(vec, ctx, key);
1,443✔
177
      return vec;
1,443✔
178
    }
179
  }
×
180

181
  add_factories<
×
182
      FW<Audio::AudioFactory, Audio::DummyFactory
183
#if defined(OSSIA_AUDIO_JACK)
184
         ,
185
         Audio::JackFactory
186
#endif
187
// #if defined(OSSIA_AUDIO_PULSEAUDIO)
188
//          ,
189
//          Audio::PulseAudioFactory
190
// #endif
191
#if OSSIA_AUDIO_ALSA
192
         ,
193
         Audio::ALSAFactory
194
#endif
195
#if defined(OSSIA_AUDIO_ASIO)
196
         ,
197
         Audio::NativeASIOFactory
198
#endif
199
#if defined(OSSIA_AUDIO_PORTAUDIO)
200
#if __has_include(<pa_asio.h>)
201
         ,
202
         Audio::ASIOFactory
203
#endif
204
//#if __has_include(<pa_win_wdmks.h>)
205
//         ,
206
//         Audio::WDMKSFactory
207
//#endif
208
#if __has_include(<pa_win_wasapi.h>)
209
         ,
210
         Audio::WASAPIFactory
211
#endif
212
//#if __has_include(<pa_win_wmme.h>)
213
//         ,
214
//         Audio::MMEFactory
215
//#endif
216
#if __has_include(<pa_linux_alsa.h>)
217
         ,
218
         Audio::ALSAPortAudioFactory
219
#endif
220
#if defined(__linux__) && defined(OSSIA_AUDIO_MINIAUDIO)
221
         ,
222
         Audio::ALSAMiniAudioFactory
223
#endif
224
#if !__has_include(<pa_asio.h>) && \
225
    !__has_include(<pa_win_wdmks.h>) && \
226
    !__has_include(<pa_win_wasapi.h>) && \
227
    !__has_include(<pa_win_wmme.h>) && \
228
    !__has_include(<pa_linux_alsa.h>) && \
229
    !__has_include(<pa_mac_core.h>)
230
         ,
231
         Audio::PortAudioFactory
232
#endif
233
#endif
234
#if defined(OSSIA_AUDIO_SDL)
235
         ,
236
         Audio::SDLFactory
237
#endif
238
#if defined(OSSIA_AUDIO_PIPEWIRE)
239
         ,
240
         Audio::PipeWireAudioFactory
241
#endif
242
#if defined(__APPLE__) && defined(OSSIA_AUDIO_MINIAUDIO)
243
         ,
244
         Audio::CoreAudioFactory
245
#endif
246
#if defined(_WIN32) && defined(OSSIA_AUDIO_MINIAUDIO)
247
         ,
248
         Audio::WASAPIMiniAudioFactory
249
#endif
250
#if defined(__EMSCRIPTEN__) && defined(OSSIA_AUDIO_MINIAUDIO)
251
         ,
252
         Audio::WASMMiniAudioFactory
253
#endif
254
         >>(vec, ctx, key);
×
255

256
  return vec;
×
257
}
1,443✔
258

259
auto score_plugin_audio::required() const -> std::vector<score::PluginKey>
39✔
260
{
261
  return {};
39✔
262
}
263

264
#include <score/plugins/PluginInstances.hpp>
265
SCORE_EXPORT_PLUGIN(score_plugin_audio)
39✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc