OpenAL Internal name

-Now there is an internal name for openal and a default name for the device to be displayed
This commit is contained in:
marauder2k7 2022-08-16 15:55:56 +01:00
parent 52dc5cf3da
commit 3eca15cb31
6 changed files with 33 additions and 14 deletions

View file

@ -82,7 +82,19 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft )
{
dMemset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO));
ALDeviceInfo.bSelected = true;
dStrncpy(ALDeviceInfo.strDeviceName, devices, sizeof(ALDeviceInfo.strDeviceName));
dStrncpy(ALDeviceInfo.strInternalDeviceName, devices, sizeof(ALDeviceInfo.strInternalDeviceName));
char* openFind = dStrchr(devices, '(');
if (openFind)
{
devices = openFind + 1;
char* closeFind = dStrchr(devices, ')');
if (closeFind)
(*closeFind) = '\0';
dStrncpy(ALDeviceInfo.strDeviceName, devices, sizeof(ALDeviceInfo.strDeviceName));
}
vDeviceInfo.push_back(ALDeviceInfo);
}
@ -111,14 +123,23 @@ int ALDeviceList::GetNumDevices()
/*
* Returns the device name at an index in the complete device list
*/
const char *ALDeviceList::GetDeviceName(int index)
const char *ALDeviceList::GetInternalDeviceName(int index)
{
if (index < GetNumDevices())
return vDeviceInfo[index].strDeviceName;
return vDeviceInfo[index].strInternalDeviceName;
else
return NULL;
}
const char* ALDeviceList::GetDeviceName(int index)
{
if (index < GetNumDevices())
return vDeviceInfo[index].strDeviceName;
else
return NULL;
}
/*
* Returns the major and minor version numbers for a device at a specified index in the complete list
*/

View file

@ -32,6 +32,7 @@
typedef struct
{
char strDeviceName[256];
char strInternalDeviceName[256];
S32 iMajorVersion;
S32 iMinorVersion;
U32 uiSourceCount;
@ -52,6 +53,7 @@ public:
~ALDeviceList ();
S32 GetNumDevices();
const char *GetDeviceName(S32 index);
const char *GetInternalDeviceName(S32 index);
void GetDeviceVersion(S32 index, S32 *major, S32 *minor);
U32 GetMaxNumSources(S32 index);
bool IsExtensionSupported(S32 index, SFXALCaps caps);

View file

@ -248,6 +248,8 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
#endif
attribs[1] = 4;
printALInfo(NULL);
mDevice = mOpenAL.alcOpenDevice( name );
U32 err = mOpenAL.alcGetError(mDevice);
if (err != ALC_NO_ERROR)

View file

@ -98,6 +98,7 @@ void SFXALProvider::init()
{
ALDeviceInfo* info = new ALDeviceInfo;
info->internalName = String( mALDL->GetInternalDeviceName( i ) );
info->name = String( mALDL->GetDeviceName( i ) );
mDeviceInfo.push_back( info );
@ -121,7 +122,7 @@ SFXDevice *SFXALProvider::createDevice( const String& deviceName, bool useHardwa
// Do we find one to create?
if (info)
return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers);
return new SFXALDevice(this, mOpenAL, info->internalName, useHardware, maxBuffers);
return NULL;
}

View file

@ -35,6 +35,7 @@ class SFXDevice;
struct SFXDeviceInfo
{
String driver;
String internalName;
String name;
bool hasHardware;
S32 maxBuffers;
@ -121,4 +122,4 @@ class SFXProvider
};
#endif // _SFXPROVIDER_H_
#endif // _SFXPROVIDER_H_

View file

@ -1265,15 +1265,7 @@ DefineEngineFunction( sfxGetAvailableDevices, const char*, (),,
const SFXDeviceInfo* info = deviceInfo[d];
const char *providerName = provider->getName().c_str();
char *infoName = (char*)info->name.c_str();
char* openFind = dStrchr(&infoName[0], '(');
if (openFind)
{
infoName = openFind + 1;
char* closeFind = dStrchr(infoName, ')');
if (closeFind)
(*closeFind) = '\0';
}
dSprintf(ptr, len, "%s\t%s\t%s\t%i\n", providerName, infoName, info->hasHardware ? "1" : "0", info->maxBuffers);
ptr += dStrlen(ptr);