summaryrefslogtreecommitdiffstats
path: root/src/audio/oal
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-06-20 20:28:53 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:32:44 +0200
commit5c1af537af94fdc1af9881d0d8e5c32f46b89e56 (patch)
tree538951e8b3edb546e8eaf3592b4271cea67f2f8f /src/audio/oal
parentFix police scanner on high fps (diff)
downloadre3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar.gz
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar.bz2
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar.lz
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar.xz
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.tar.zst
re3-5c1af537af94fdc1af9881d0d8e5c32f46b89e56.zip
Diffstat (limited to 'src/audio/oal')
-rw-r--r--src/audio/oal/aldlist.cpp26
-rw-r--r--src/audio/oal/aldlist.h15
2 files changed, 20 insertions, 21 deletions
diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp
index 881418c1..6024adf2 100644
--- a/src/audio/oal/aldlist.cpp
+++ b/src/audio/oal/aldlist.cpp
@@ -24,12 +24,6 @@
#include "aldlist.h"
-#ifndef _WIN32
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#define _strdup strdup
-#endif
-
#ifdef AUDIO_OAL
/*
* Init call
@@ -47,8 +41,8 @@ ALDeviceList::ALDeviceList()
defaultDeviceIndex = 0;
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) {
- devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
- defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
+ devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
+ defaultDeviceName = (char *)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)
@@ -62,17 +56,11 @@ ALDeviceList::ALDeviceList()
if (context) {
alcMakeContextCurrent(context);
// if new actual device name isn't already in the list, then add it...
- actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER);
- bool bNewName = true;
- for (unsigned int i = 0; i < GetNumDevices(); i++) {
- if (strcmp(GetDeviceName(i), actualDeviceName) == 0) {
- bNewName = false;
- }
- }
- if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) {
- ALDEVICEINFO ALDeviceInfo;
+ actualDeviceName = alcGetString(device, ALC_ALL_DEVICES_SPECIFIER);
+ if ((actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) {
+ ALDEVICEINFO &ALDeviceInfo = aDeviceInfo[nNumOfDevices++];
ALDeviceInfo.bSelected = true;
- ALDeviceInfo.strDeviceName = _strdup(actualDeviceName);
+ ALDeviceInfo.SetName(actualDeviceName);
alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion);
alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion);
@@ -105,8 +93,6 @@ ALDeviceList::ALDeviceList()
// Get Source Count
ALDeviceInfo.uiSourceCount = GetMaxNumSources();
-
- aDeviceInfo[nNumOfDevices++] = ALDeviceInfo;
}
alcMakeContextCurrent(NULL);
alcDestroyContext(context);
diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h
index 417bd314..3ed12d84 100644
--- a/src/audio/oal/aldlist.h
+++ b/src/audio/oal/aldlist.h
@@ -21,7 +21,7 @@ enum
};
struct ALDEVICEINFO {
- const char *strDeviceName;
+ char *strDeviceName;
int iMajorVersion;
int iMinorVersion;
unsigned int uiSourceCount;
@@ -33,6 +33,19 @@ struct ALDEVICEINFO {
strDeviceName = NULL;
Extensions = 0;
}
+
+ ~ALDEVICEINFO()
+ {
+ delete[] strDeviceName;
+ strDeviceName = NULL;
+ }
+
+ void SetName(const char *name)
+ {
+ if(strDeviceName) delete[] strDeviceName;
+ strDeviceName = new char[strlen(name) + 1];
+ strcpy(strDeviceName, name);
+ }
};
typedef ALDEVICEINFO *LPALDEVICEINFO;