diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index d0bfcc091..0a8468b1a 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -227,6 +227,8 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) return newJuce(AUDIO_API_ASIO); if (std::strcmp(driverName, "DirectSound") == 0) return newJuce(AUDIO_API_DIRECTSOUND); + if (std::strcmp(driverName, "WASAPI") == 0 || std::strcmp(driverName, "Windows Audio") == 0) + return newJuce(AUDIO_API_WASAPI); # else // ------------------------------------------------------------------- // common diff --git a/source/backend/engine/CarlaEngineJuce.cpp b/source/backend/engine/CarlaEngineJuce.cpp index 9d33ee348..f78bd8782 100644 --- a/source/backend/engine/CarlaEngineJuce.cpp +++ b/source/backend/engine/CarlaEngineJuce.cpp @@ -88,6 +88,14 @@ struct JuceCleanup : public juce::DeletedAtShutdown { // ------------------------------------------------------------------------------------------------------------------- // Cleanup +struct AudioIODeviceTypeComparator +{ + static int compareElements (const juce::AudioIODeviceType* d1, const juce::AudioIODeviceType* d2) noexcept + { + return d1->getTypeName().compareNatural (d2->getTypeName()); + } +}; + static void initJuceDevicesIfNeeded() { static juce::AudioDeviceManager sDeviceManager; @@ -110,6 +118,9 @@ static void initJuceDevicesIfNeeded() break; } } + + AudioIODeviceTypeComparator comp; + gDeviceTypes.sort(comp); } // ------------------------------------------------------------------------------------------------------------------- @@ -831,7 +842,6 @@ CarlaEngine* CarlaEngine::newJuce(const AudioApi api) case AUDIO_API_NULL: case AUDIO_API_OSS: case AUDIO_API_PULSEAUDIO: - case AUDIO_API_WASAPI: break; case AUDIO_API_JACK: juceApi = "JACK"; @@ -848,6 +858,9 @@ CarlaEngine* CarlaEngine::newJuce(const AudioApi api) case AUDIO_API_DIRECTSOUND: juceApi = "DirectSound"; break; + case AUDIO_API_WASAPI: + juceApi = "Windows Audio"; + break; } if (juceApi.isEmpty()) diff --git a/source/modules/AppConfig.h b/source/modules/AppConfig.h index 50f40d325..032740f85 100644 --- a/source/modules/AppConfig.h +++ b/source/modules/AppConfig.h @@ -115,7 +115,11 @@ /** Config: JUCE_WASAPI Enables WASAPI audio devices (Windows Vista and above). */ -#define JUCE_WASAPI 0 +#if defined(APPCONFIG_OS_WIN) && !defined(BUILDING_CARLA_NOOPT) + #define JUCE_WASAPI 1 +#else + #define JUCE_WASAPI 0 +#endif /** Config: JUCE_DIRECTSOUND Enables DirectSound audio (MS Windows only). diff --git a/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index d0380d789..4635c8914 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -994,8 +994,8 @@ public: isStarted (false), currentBufferSizeSamples (0), currentSampleRate (0), - callback (nullptr), - deviceBecameInactive (false) + deviceBecameInactive (false), + callback (nullptr) { } @@ -1716,9 +1716,7 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool exclu return nullptr; #endif - return SystemStats::getOperatingSystemType() >= SystemStats::WinVista - ? new WasapiClasses::WASAPIAudioIODeviceType (exclusiveMode) - : nullptr; + return new WasapiClasses::WASAPIAudioIODeviceType (exclusiveMode); } //==============================================================================