Browse Source

OpenAL Internal name

-Now there is an internal name for openal and a default name for the device to be displayed
marauder2k7 3 years ago
parent
commit
3eca15cb31

+ 24 - 3
Engine/source/sfx/openal/aldlist.cpp

@@ -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
  */

+ 2 - 0
Engine/source/sfx/openal/aldlist.h

@@ -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);

+ 2 - 0
Engine/source/sfx/openal/sfxALDevice.cpp

@@ -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)

+ 2 - 1
Engine/source/sfx/openal/sfxALProvider.cpp

@@ -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;
 }

+ 2 - 1
Engine/source/sfx/sfxProvider.h

@@ -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_

+ 1 - 9
Engine/source/sfx/sfxSystem.cpp

@@ -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);