Browse Source

Added new flag JUCE_WASAPI_EXCLUSIVE that provides a new audio device type for opening WASAPI devices in exclusive mode.

tags/2021-05-28
jules 10 years ago
parent
commit
c0ade582d8
5 changed files with 26 additions and 12 deletions
  1. +1
    -1
      modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp
  2. +1
    -1
      modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h
  3. +10
    -1
      modules/juce_audio_devices/juce_audio_devices.h
  4. +1
    -0
      modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  5. +13
    -9
      modules/juce_audio_devices/native/juce_win32_WASAPI.cpp

+ 1
- 1
modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp View File

@@ -50,7 +50,7 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_iOSAudio()
#endif #endif
#if ! (JUCE_WINDOWS && JUCE_WASAPI) #if ! (JUCE_WINDOWS && JUCE_WASAPI)
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI() { return nullptr; }
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool) { return nullptr; }
#endif #endif
#if ! (JUCE_WINDOWS && JUCE_DIRECTSOUND) #if ! (JUCE_WINDOWS && JUCE_DIRECTSOUND)


+ 1
- 1
modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h View File

@@ -151,7 +151,7 @@ public:
/** Creates an iOS device type if it's available on this platform, or returns null. */ /** Creates an iOS device type if it's available on this platform, or returns null. */
static AudioIODeviceType* createAudioIODeviceType_iOSAudio(); static AudioIODeviceType* createAudioIODeviceType_iOSAudio();
/** Creates a WASAPI device type if it's available on this platform, or returns null. */ /** 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. */ /** Creates a DirectSound device type if it's available on this platform, or returns null. */
static AudioIODeviceType* createAudioIODeviceType_DirectSound(); static AudioIODeviceType* createAudioIODeviceType_DirectSound();
/** Creates an ASIO device type if it's available on this platform, or returns null. */ /** Creates an ASIO device type if it's available on this platform, or returns null. */


+ 10
- 1
modules/juce_audio_devices/juce_audio_devices.h View File

@@ -43,12 +43,21 @@
#endif #endif
/** Config: JUCE_WASAPI /** 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 #ifndef JUCE_WASAPI
#define JUCE_WASAPI 1 #define JUCE_WASAPI 1
#endif #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 /** Config: JUCE_DIRECTSOUND
Enables DirectSound audio (MS Windows only). Enables DirectSound audio (MS Windows only).
*/ */


+ 1
- 0
modules/juce_audio_devices/native/juce_win32_ASIO.cpp View File

@@ -1409,6 +1409,7 @@ private:
if (currentASIODev[0] == this) ASIOCallbackFunctions<0>::setCallbacks (callbacks); if (currentASIODev[0] == this) ASIOCallbackFunctions<0>::setCallbacks (callbacks);
else if (currentASIODev[1] == this) ASIOCallbackFunctions<1>::setCallbacks (callbacks); else if (currentASIODev[1] == this) ASIOCallbackFunctions<1>::setCallbacks (callbacks);
else if (currentASIODev[2] == this) ASIOCallbackFunctions<2>::setCallbacks (callbacks); else if (currentASIODev[2] == this) ASIOCallbackFunctions<2>::setCallbacks (callbacks);
else if (currentASIODev[3] == this) ASIOCallbackFunctions<3>::setCallbacks (callbacks);
else jassertfalse; else jassertfalse;
} }


+ 13
- 9
modules/juce_audio_devices/native/juce_win32_WASAPI.cpp View File

@@ -1208,9 +1208,10 @@ class WASAPIAudioIODeviceType : public AudioIODeviceType,
private DeviceChangeDetector private DeviceChangeDetector
{ {
public: public:
WASAPIAudioIODeviceType()
: AudioIODeviceType ("Windows Audio"),
WASAPIAudioIODeviceType (bool exclusive)
: AudioIODeviceType (exclusive ? "Windows Audio (Exclusive Mode)" : "Windows Audio"),
DeviceChangeDetector (L"Windows Audio"), DeviceChangeDetector (L"Windows Audio"),
exclusiveMode (exclusive),
hasScanned (false) hasScanned (false)
{ {
} }
@@ -1267,7 +1268,6 @@ public:
{ {
jassert (hasScanned); // need to call scanForDevices() before doing this jassert (hasScanned); // need to call scanForDevices() before doing this
const bool useExclusiveMode = false;
ScopedPointer<WASAPIAudioIODevice> device; ScopedPointer<WASAPIAudioIODevice> device;
const int outputIndex = outputDeviceNames.indexOf (outputDeviceName); const int outputIndex = outputDeviceNames.indexOf (outputDeviceName);
@@ -1279,7 +1279,7 @@ public:
: inputDeviceName, : inputDeviceName,
outputDeviceIds [outputIndex], outputDeviceIds [outputIndex],
inputDeviceIds [inputIndex], inputDeviceIds [inputIndex],
useExclusiveMode);
exclusiveMode);
if (! device->initialise()) if (! device->initialise())
device = nullptr; device = nullptr;
@@ -1293,7 +1293,7 @@ public:
StringArray inputDeviceNames, inputDeviceIds; StringArray inputDeviceNames, inputDeviceIds;
private: private:
bool hasScanned;
bool exclusiveMode, hasScanned;
ComSmartPtr<IMMDeviceEnumerator> enumerator; 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…
Cancel
Save