mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added new flag JUCE_WASAPI_EXCLUSIVE that provides a new audio device type for opening WASAPI devices in exclusive mode.
This commit is contained in:
parent
5d3e24b7a7
commit
c0ade582d8
5 changed files with 26 additions and 12 deletions
|
|
@ -50,7 +50,7 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_iOSAudio()
|
|||
#endif
|
||||
|
||||
#if ! (JUCE_WINDOWS && JUCE_WASAPI)
|
||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI() { return nullptr; }
|
||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool) { return nullptr; }
|
||||
#endif
|
||||
|
||||
#if ! (JUCE_WINDOWS && JUCE_DIRECTSOUND)
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public:
|
|||
/** Creates an iOS device type if it's available on this platform, or returns null. */
|
||||
static AudioIODeviceType* createAudioIODeviceType_iOSAudio();
|
||||
/** Creates a WASAPI device type if it's available on this platform, or returns null. */
|
||||
static AudioIODeviceType* createAudioIODeviceType_WASAPI();
|
||||
static AudioIODeviceType* createAudioIODeviceType_WASAPI (bool exclusiveMode);
|
||||
/** Creates a DirectSound device type if it's available on this platform, or returns null. */
|
||||
static AudioIODeviceType* createAudioIODeviceType_DirectSound();
|
||||
/** Creates an ASIO device type if it's available on this platform, or returns null. */
|
||||
|
|
|
|||
|
|
@ -43,12 +43,21 @@
|
|||
#endif
|
||||
|
||||
/** Config: JUCE_WASAPI
|
||||
Enables WASAPI audio devices (Windows Vista and above).
|
||||
Enables WASAPI audio devices (Windows Vista and above). See also the
|
||||
JUCE_WASAPI_EXCLUSIVE flag.
|
||||
*/
|
||||
#ifndef JUCE_WASAPI
|
||||
#define JUCE_WASAPI 1
|
||||
#endif
|
||||
|
||||
/** Config: JUCE_WASAPI_EXCLUSIVE
|
||||
Enables WASAPI audio devices in exclusive mode (Windows Vista and above).
|
||||
*/
|
||||
#ifndef JUCE_WASAPI_EXCLUSIVE
|
||||
#define JUCE_WASAPI_EXCLUSIVE 0
|
||||
#endif
|
||||
|
||||
|
||||
/** Config: JUCE_DIRECTSOUND
|
||||
Enables DirectSound audio (MS Windows only).
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1409,6 +1409,7 @@ private:
|
|||
if (currentASIODev[0] == this) ASIOCallbackFunctions<0>::setCallbacks (callbacks);
|
||||
else if (currentASIODev[1] == this) ASIOCallbackFunctions<1>::setCallbacks (callbacks);
|
||||
else if (currentASIODev[2] == this) ASIOCallbackFunctions<2>::setCallbacks (callbacks);
|
||||
else if (currentASIODev[3] == this) ASIOCallbackFunctions<3>::setCallbacks (callbacks);
|
||||
else jassertfalse;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1208,9 +1208,10 @@ class WASAPIAudioIODeviceType : public AudioIODeviceType,
|
|||
private DeviceChangeDetector
|
||||
{
|
||||
public:
|
||||
WASAPIAudioIODeviceType()
|
||||
: AudioIODeviceType ("Windows Audio"),
|
||||
WASAPIAudioIODeviceType (bool exclusive)
|
||||
: AudioIODeviceType (exclusive ? "Windows Audio (Exclusive Mode)" : "Windows Audio"),
|
||||
DeviceChangeDetector (L"Windows Audio"),
|
||||
exclusiveMode (exclusive),
|
||||
hasScanned (false)
|
||||
{
|
||||
}
|
||||
|
|
@ -1267,7 +1268,6 @@ public:
|
|||
{
|
||||
jassert (hasScanned); // need to call scanForDevices() before doing this
|
||||
|
||||
const bool useExclusiveMode = false;
|
||||
ScopedPointer<WASAPIAudioIODevice> device;
|
||||
|
||||
const int outputIndex = outputDeviceNames.indexOf (outputDeviceName);
|
||||
|
|
@ -1279,7 +1279,7 @@ public:
|
|||
: inputDeviceName,
|
||||
outputDeviceIds [outputIndex],
|
||||
inputDeviceIds [inputIndex],
|
||||
useExclusiveMode);
|
||||
exclusiveMode);
|
||||
|
||||
if (! device->initialise())
|
||||
device = nullptr;
|
||||
|
|
@ -1293,7 +1293,7 @@ public:
|
|||
StringArray inputDeviceNames, inputDeviceIds;
|
||||
|
||||
private:
|
||||
bool hasScanned;
|
||||
bool exclusiveMode, hasScanned;
|
||||
ComSmartPtr<IMMDeviceEnumerator> enumerator;
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -1493,12 +1493,16 @@ struct MMDeviceMasterVolume
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI()
|
||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool exclusiveMode)
|
||||
{
|
||||
if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista)
|
||||
return new WasapiClasses::WASAPIAudioIODeviceType();
|
||||
#if ! JUCE_WASAPI_EXCLUSIVE
|
||||
if (exclusiveMode)
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
return SystemStats::getOperatingSystemType() >= SystemStats::WinVista
|
||||
? new WasapiClasses::WASAPIAudioIODeviceType (exclusiveMode)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue