From 5e88ab25708cb9771d99fb5b1e5c02d94586a9d6 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Fri, 1 Oct 2021 21:34:45 -0400 Subject: [PATCH 1/3] * BugFix: Fix AL device listing so that functions like sfxGetAvailableDevices return the actual devices on the system. --- Engine/source/sfx/openal/aldlist.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index a453579e3..8f7c0d4a6 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -56,7 +56,7 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { - devices = (char *)ALFunction.alcGetString(NULL, ALC_DEVICE_SPECIFIER); + devices = (char *)ALFunction.alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) @@ -70,7 +70,7 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) if (context) { ALFunction.alcMakeContextCurrent(context); // if new actual device name isn't already in the list, then add it... - actualDeviceName = ALFunction.alcGetString(device, ALC_DEVICE_SPECIFIER); + actualDeviceName = devices; bool bNewName = true; for (int i = 0; i < GetNumDevices(); i++) { if (String::compare(GetDeviceName(i), actualDeviceName) == 0) { @@ -313,4 +313,4 @@ unsigned int ALDeviceList::GetMaxNumSources() } return iSourceCount; -} \ No newline at end of file +} From 43630c31c2938efb107eca01494fd73633e56fea Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sat, 2 Oct 2021 22:24:11 -0400 Subject: [PATCH 2/3] * BugFix: Tweaks to the ALC device listing logic to be more consistent with the AL API. --- Engine/source/sfx/openal/aldlist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 8f7c0d4a6..51f5a3b51 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -55,9 +55,9 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) defaultDeviceIndex = 0; // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices - if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { + if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT")) { devices = (char *)ALFunction.alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); - defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) while (*devices != 0) { From 6a94946e5b1621b2e0e2bdce45e016816f247b21 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sat, 2 Oct 2021 22:29:34 -0400 Subject: [PATCH 3/3] * BugFix: Fallback to ALC_ENUMERATION_EXT if ALC_ENUMERATE_ALL_EXT is not available. --- Engine/source/sfx/openal/aldlist.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 51f5a3b51..73307f50b 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -55,9 +55,20 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) defaultDeviceIndex = 0; // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices - if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT")) { - devices = (char *)ALFunction.alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); - defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + const bool enumerationExtensionPresent = ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"); + const bool enumerateAllExtensionPresent = ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"); + if (enumerateAllExtensionPresent || enumerationExtensionPresent) { + if (enumerateAllExtensionPresent) + { + devices = (char *)ALFunction.alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + } + else + { + devices = (char *)ALFunction.alcGetString(NULL, ALC_DEVICE_SPECIFIER); + defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + } + index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) while (*devices != 0) {