OpenShot Audio Library | OpenShotAudio 0.4.0
 
Loading...
Searching...
No Matches
juce_audio_devices.cpp
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23#ifdef JUCE_AUDIO_DEVICES_H_INCLUDED
24 /* When you add this cpp file to your project, you mustn't include it in a file where you've
25 already included any other headers - just put it inside a file on its own, possibly with your config
26 flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
27 header files that the compiler may be using.
28 */
29 #error "Incorrect use of JUCE cpp file"
30#endif
31
32#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
33#define JUCE_CORE_INCLUDE_COM_SMART_PTR 1
34#define JUCE_CORE_INCLUDE_JNI_HELPERS 1
35#define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
36#define JUCE_EVENTS_INCLUDE_WIN32_MESSAGE_WINDOW 1
37
38#ifndef JUCE_USE_WINRT_MIDI
39 #define JUCE_USE_WINRT_MIDI 0
40#endif
41
42#if JUCE_USE_WINRT_MIDI
43 #define JUCE_EVENTS_INCLUDE_WINRT_WRAPPER 1
44#endif
45
46#include "juce_audio_devices.h"
47
48#include "audio_io/juce_SampleRateHelpers.cpp"
49#include "midi_io/juce_MidiDevices.cpp"
50
51//==============================================================================
52#if JUCE_MAC || JUCE_IOS
53 #include <juce_audio_basics/native/juce_CoreAudioTimeConversions_mac.h>
54 #include <juce_audio_basics/native/juce_AudioWorkgroup_mac.h>
55 #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
56 #include <juce_audio_basics/midi/ump/juce_UMP.h>
57 #include "midi_io/ump/juce_UMPBytestreamInputHandler.h"
58 #include "midi_io/ump/juce_UMPU32InputHandler.h"
59#endif
60
61#if JUCE_MAC
62 #define Point CarbonDummyPointName
63 #define Component CarbonDummyCompName
64 #import <CoreAudio/AudioHardware.h>
65 #import <CoreMIDI/MIDIServices.h>
66 #import <AudioToolbox/AudioServices.h>
67 #undef Point
68 #undef Component
69
70 #include "native/juce_CoreAudio_mac.cpp"
71 #include "native/juce_CoreMidi_mac.mm"
72
73#elif JUCE_IOS
74 #import <AudioToolbox/AudioToolbox.h>
75 #import <AVFoundation/AVFoundation.h>
76 #import <CoreMIDI/MIDIServices.h>
77
78 #if TARGET_OS_SIMULATOR
79 #import <CoreMIDI/MIDINetworkSession.h>
80 #endif
81
82 #if JUCE_MODULE_AVAILABLE_juce_graphics
83 #include <juce_graphics/native/juce_CoreGraphicsHelpers_mac.h>
84 #endif
85
86 #include "native/juce_Audio_ios.cpp"
87 #include "native/juce_CoreMidi_mac.mm"
88
89//==============================================================================
90#elif JUCE_WINDOWS
91 #if JUCE_WASAPI
92 #include <mmreg.h>
93 #include "native/juce_WASAPI_windows.cpp"
94 #endif
95
96 #if JUCE_DIRECTSOUND
97 #include "native/juce_DirectSound_windows.cpp"
98 #endif
99
100 #if JUCE_USE_WINRT_MIDI && (JUCE_MSVC || JUCE_CLANG)
101 /* If you cannot find any of the header files below then you are probably
102 attempting to use the Windows 10 Bluetooth Low Energy API. For this to work you
103 need to install version 10.0.14393.0 of the Windows Standalone SDK and you may
104 need to add the path to the WinRT headers to your build system. This path should
105 have the form "C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\winrt".
106
107 Also please note that Microsoft's Bluetooth MIDI stack has multiple issues, so
108 this API is EXPERIMENTAL - use at your own risk!
109 */
110 #include <windows.devices.h>
111 #include <windows.devices.midi.h>
112 #include <windows.devices.enumeration.h>
113
114 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4265)
115 #include <wrl/event.h>
116 JUCE_END_IGNORE_WARNINGS_MSVC
117
118 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4467)
119 #include <robuffer.h>
120 JUCE_END_IGNORE_WARNINGS_MSVC
121 #endif
122
123 #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
124 #include "native/juce_Midi_windows.cpp"
125
126 #if JUCE_ASIO
127 /* This is very frustrating - we only need to use a handful of definitions from
128 a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy
129 about 30 lines of code into this cpp file to create a fully stand-alone ASIO
130 implementation...
131
132 ..unfortunately that would break Steinberg's license agreement for use of
133 their SDK, so I'm not allowed to do this.
134
135 This means that anyone who wants to use JUCE's ASIO abilities will have to:
136
137 1) Agree to Steinberg's licensing terms and download the ASIO SDK
138 (see http://www.steinberg.net/en/company/developers.html).
139
140 2) Enable this code with a global definition #define JUCE_ASIO 1.
141
142 3) Make sure that your header search path contains the iasiodrv.h file that
143 comes with the SDK. (Only about a handful of the SDK header files are actually
144 needed - so to simplify things, you could just copy these into your JUCE directory).
145 */
146 #include <iasiodrv.h>
147 #include "native/juce_ASIO_windows.cpp"
148 #endif
149
150//==============================================================================
151#elif JUCE_LINUX || JUCE_BSD
152 #if JUCE_ALSA
153 /* Got an include error here? If so, you've either not got ALSA installed, or you've
154 not got your paths set up correctly to find its header files.
155
156 The package you need to install to get ASLA support is "libasound2-dev".
157
158 If you don't have the ALSA library and don't want to build JUCE with audio support,
159 just set the JUCE_ALSA flag to 0.
160 */
161 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-length-array")
162 #include <alsa/asoundlib.h>
163 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
164 #include "native/juce_ALSA_linux.cpp"
165 #endif
166
167 #if JUCE_JACK
168 /* Got an include error here? If so, you've either not got jack-audio-connection-kit
169 installed, or you've not got your paths set up correctly to find its header files.
170
171 The package you need to install to get JACK support is "libjack-dev".
172
173 If you don't have the jack-audio-connection-kit library and don't want to build
174 JUCE with low latency audio support, just set the JUCE_JACK flag to 0.
175 */
176 #include <jack/jack.h>
177 #include "native/juce_JackAudio_linux.cpp"
178 #endif
179
180 #if (JUCE_LINUX && JUCE_BELA)
181 /* Got an include error here? If so, you've either not got the bela headers
182 installed, or you've not got your paths set up correctly to find its header
183 files.
184 */
185 #include <Bela.h>
186 #include <Midi.h>
187 #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
188 #include "native/juce_Bela_linux.cpp"
189 #endif
190
191 #undef SIZEOF
192
193 #if ! JUCE_BELA
194 #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
195 #include "native/juce_Midi_linux.cpp"
196 #endif
197
198//==============================================================================
199#elif JUCE_ANDROID
200
201namespace juce
202{
203 using RealtimeThreadFactory = pthread_t (*) (void* (*) (void*), void*);
204 RealtimeThreadFactory getAndroidRealtimeThreadFactory();
205} // namespace juce
206
207#include "native/juce_Audio_android.cpp"
208
209 #include <juce_audio_basics/midi/juce_MidiDataConcatenator.h>
210 #include "native/juce_Midi_android.cpp"
211
212 #if JUCE_USE_ANDROID_OPENSLES || JUCE_USE_ANDROID_OBOE
213 #include "native/juce_HighPerformanceAudioHelpers_android.h"
214
215 #if JUCE_USE_ANDROID_OPENSLES
216 #include <SLES/OpenSLES.h>
217 #include <SLES/OpenSLES_Android.h>
218 #include <SLES/OpenSLES_AndroidConfiguration.h>
219 #include "native/juce_OpenSL_android.cpp"
220 #endif
221
222 #if JUCE_USE_ANDROID_OBOE
223 #if JUCE_USE_ANDROID_OPENSLES
224 #error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES"
225 #endif
226
227 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter",
228 "-Wzero-as-null-pointer-constant",
229 "-Winconsistent-missing-destructor-override",
230 "-Wshadow-field-in-constructor",
231 "-Wshadow-field",
232 "-Wsign-conversion",
233 "-Wswitch-enum")
234 #include <oboe/Oboe.h>
235 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
236
237 #include "native/juce_Oboe_android.cpp"
238 #endif
239 #else
240// No audio library, so no way to create realtime threads.
241 namespace juce
242 {
243 RealtimeThreadFactory getAndroidRealtimeThreadFactory() { return nullptr; }
244 }
245 #endif
246
247#endif
248
249#if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED
250namespace juce
251{
252 // None of these methods are available. (On Windows you might need to enable WASAPI for this)
253 float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; }
254 bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; }
255 bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; }
256 bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; }
257}
258#endif
259
260#include "audio_io/juce_AudioDeviceManager.cpp"
261#include "audio_io/juce_AudioIODevice.cpp"
262#include "audio_io/juce_AudioIODeviceType.cpp"
263#include "midi_io/juce_MidiMessageCollector.cpp"
264#include "sources/juce_AudioSourcePlayer.cpp"
265#include "sources/juce_AudioTransportSource.cpp"
static bool JUCE_CALLTYPE setMuted(bool shouldBeMuted)
static float JUCE_CALLTYPE getGain()
static bool JUCE_CALLTYPE isMuted()
static bool JUCE_CALLTYPE setGain(float newGain)