diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp index 80026e7ae5..bdce8f45d2 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp @@ -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) diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h index d6cd99a5a6..debfdb22ee 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h @@ -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. */ diff --git a/modules/juce_audio_devices/juce_audio_devices.h b/modules/juce_audio_devices/juce_audio_devices.h index b8528d5bc3..fd63c6ff75 100644 --- a/modules/juce_audio_devices/juce_audio_devices.h +++ b/modules/juce_audio_devices/juce_audio_devices.h @@ -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). */ diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index 3e34294d97..b2bca4fe6a 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -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; } diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 0ef7811d45..2eac2fb3cc 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -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 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 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; } //==============================================================================