openal-soft icon indicating copy to clipboard operation
openal-soft copied to clipboard

Ever since update only returning one device?

Open marauder2k7 opened this issue 2 years ago • 6 comments

ever since the update to 1.22.2 this code

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);
   }
   else
   {
       devices = (char *)ALFunction.alcGetString(NULL, ALC_DEVICE_SPECIFIER);
       defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
   }

is only returning one device into devices, before it was returning all the devices in the system.

will note the AL logging output is recording that it sees both devices on this system.

[ALSOFT] (II) Got device "Speakers (SXFI GAMER)", "{39B0CBAD-85A3-4A8F-8715-26AEE0A73E52}", "{0.0.0.00000000}.{39b0cbad-85a3-4a8f-8715-26aee0a73e52}"
[ALSOFT] (II) Got device "Speakers (Sound BlasterX AE-5 Plus)", "{11222511-0711-4B77-874B-AB495D32FA09}", "{0.0.0.00000000}.{11222511-0711-4b77-874b-ab495d32fa09}"

marauder2k7 avatar Aug 16 '22 20:08 marauder2k7

How are you checking the returned names? For the ALC_ALL_DEVICES_SPECIFIER and ALC_DEVICE_SPECIFIER strings, the names are separated by null characters, and is finished by a blank name.

kcat avatar Aug 16 '22 20:08 kcat

i can share a link to the source code: https://github.com/TorqueGameEngines/Torque3D/blob/development/Engine/source/sfx/openal/aldlist.cpp

I am working on a refactor of the entire sound system atm and want to go 100% openal-soft and use its latest features. The idea of this code is to split the OpenAL Soft on Speakers (' deviceName ') so that in the options menu it just shows the device name for people

marauder2k7 avatar Aug 17 '22 07:08 marauder2k7

You're modifying the returned devices list:

char* openFind = dStrchr(devices, '(');
if (openFind)
{
   devices = openFind + 1;
   char* closeFind = dStrchr(devices, ')');
   if (closeFind)
      (*closeFind) = '\0';

The returned string is const char*, so you must not modify it. In this case, it's causing the last character of the name (which is )) to be overwritten with a null char, so the subsequent dStrlen counts up to what would have been ), with the next character being the real null char for the name instead of the start of the next name, which causes the loop to break thinking it found an empty name.

Be aware also that the format of the device string isn't guaranteed. It's based on the name returned by the system, but different systems may format device names differently. Even Windows isn't guaranteed to name devices the same way in the future. There's also no guarantee the device name won't itself contain another pair of (/) chars, which would break the logic. It's best to not assume anything about the device names returned by OpenAL Soft, other than they're user-readable UTF-8 strings.

kcat avatar Aug 17 '22 10:08 kcat

yeah i just noticed my mistake, rather stupid moment after coding for hours lol sorry about that.

Just curious is there a faster way to load all of openal-soft? i noticed the router class but unsure if its meant to be used internally or can it be used by our game engine?

marauder2k7 avatar Aug 17 '22 20:08 marauder2k7

What's being slow to load?

The router is a separate DLL that manages multiple OpenAL implementations, so you can link directly to one OpenAL and use the standard functions, and get access to all implementations on the system, be it OpenAL Soft, Rapture3D, Creative's wrapper driver, a hardware driver, etc. They'll all be shown as separate devices for enumeration, and which device you open will then determine which implementation is in use and what extensions will be available. Since you're going 100% OpenAL Soft for its newest features, it won't benefit you.

kcat avatar Aug 17 '22 21:08 kcat

Its not that anything is taking a particularly long time to load its just making use of the new features is sometimes been abit of a hassle lol

this is the reference point for the rest of the engine for the openal functions: https://github.com/TorqueGameEngines/Torque3D/blob/development/Engine/source/sfx/openal/LoadOAL.h

and this is where we are checking the dll for the procaddresses: https://github.com/TorqueGameEngines/Torque3D/blob/development/Engine/source/sfx/openal/win32/LoadOAL.cpp

We are going to be pushing people to go down the openal-soft route, i want to make it a more concrete implementation and make use of all its features

I am working on making that process easier with this

https://github.com/marauder2k9-torque/Torque3D/commit/44d5b73e43cd4111e20cb2ce7eac2663e51feea2

it pretty much does similar to the router class

marauder2k7 avatar Aug 17 '22 21:08 marauder2k7