From 6bf79120dcd535dc6a63c4d0da858444facb0d8d Mon Sep 17 00:00:00 2001 From: shfil Date: Mon, 18 May 2020 21:08:01 +0200 Subject: Fix string assignment (aldlist.cpp) --- src/audio/oal/aldlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 458b7c80..7401e036 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -73,7 +73,7 @@ ALDeviceList::ALDeviceList() if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); ALDeviceInfo.bSelected = true; - ALDeviceInfo.strDeviceName.assign(actualDeviceName, strlen(actualDeviceName)); + ALDeviceInfo.strDeviceName = actualDeviceName; alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); -- cgit v1.2.3 From e858314a9f1c0adb0a8c2ec2dd1536e111932650 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 22 May 2020 18:00:18 +0300 Subject: OpenAL configs --- src/audio/oal/channel.cpp | 4 ++-- src/audio/oal/channel.h | 1 - src/audio/oal/oal_utils.cpp | 1 + src/audio/oal/oal_utils.h | 1 - src/audio/oal/stream.cpp | 8 ++++---- src/audio/oal/stream.h | 1 - 6 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 6fe1d856..731e3581 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -1,7 +1,7 @@ -#include "channel.h" +#include "common.h" #ifdef AUDIO_OAL -#include "common.h" +#include "channel.h" #include "sampman.h" #ifndef _WIN32 diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h index 4dd09ca1..0c86bdc6 100644 --- a/src/audio/oal/channel.h +++ b/src/audio/oal/channel.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #ifdef AUDIO_OAL #include "oal/oal_utils.h" diff --git a/src/audio/oal/oal_utils.cpp b/src/audio/oal/oal_utils.cpp index 4119672f..e16de572 100644 --- a/src/audio/oal/oal_utils.cpp +++ b/src/audio/oal/oal_utils.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include "oal_utils.h" #ifdef AUDIO_OAL diff --git a/src/audio/oal/oal_utils.h b/src/audio/oal/oal_utils.h index af45a944..b89ccf36 100644 --- a/src/audio/oal/oal_utils.h +++ b/src/audio/oal/oal_utils.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #ifdef AUDIO_OAL #include "eax.h" diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 5a9c7d7d..34518f54 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -1,11 +1,9 @@ -#include "stream.h" +#include "common.h" #ifdef AUDIO_OAL -#include "common.h" +#include "stream.h" #include "sampman.h" -#include -#include #ifdef _WIN32 typedef long ssize_t; #pragma comment( lib, "libsndfile-1.lib" ) @@ -13,6 +11,8 @@ typedef long ssize_t; #else #include "crossplatform.h" #endif +#include +#include class CSndFile : public IDecoder { diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index f1e5f458..456c080a 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #ifdef AUDIO_OAL #include -- cgit v1.2.3 From a9f332f2d96b6a8b6f83b5da5c1c320d2ff4eab2 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 22 May 2020 21:26:31 +0300 Subject: Possibly fix travis --- src/audio/oal/stream.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 34518f54..c70cd2c1 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -8,11 +8,12 @@ typedef long ssize_t; #pragma comment( lib, "libsndfile-1.lib" ) #pragma comment( lib, "libmpg123.lib" ) -#else -#include "crossplatform.h" #endif #include #include +#ifndef _WIN32 +#include "crossplatform.h" +#endif class CSndFile : public IDecoder { -- cgit v1.2.3 From c993e99e0086aae50357c8ffa180de54396ede92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 22 May 2020 22:49:54 +0300 Subject: Fix linux build --- src/audio/oal/stream.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index c70cd2c1..34518f54 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -8,12 +8,11 @@ typedef long ssize_t; #pragma comment( lib, "libsndfile-1.lib" ) #pragma comment( lib, "libmpg123.lib" ) +#else +#include "crossplatform.h" #endif #include #include -#ifndef _WIN32 -#include "crossplatform.h" -#endif class CSndFile : public IDecoder { -- cgit v1.2.3 From 7d30878418e037bcfda4121f59193e25a89c1824 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 24 May 2020 01:06:19 +0300 Subject: Fix OAL crash --- src/audio/oal/aldlist.cpp | 3 +-- src/audio/oal/aldlist.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 7401e036..9834ffb4 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -35,7 +35,6 @@ */ ALDeviceList::ALDeviceList() { - ALDEVICEINFO ALDeviceInfo; char *devices; int index; const char *defaultDeviceName; @@ -71,7 +70,7 @@ ALDeviceList::ALDeviceList() } } if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { - memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); + ALDEVICEINFO ALDeviceInfo; ALDeviceInfo.bSelected = true; ALDeviceInfo.strDeviceName = actualDeviceName; alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h index 694c9d01..3afa6bfe 100644 --- a/src/audio/oal/aldlist.h +++ b/src/audio/oal/aldlist.h @@ -8,15 +8,20 @@ #include #include -typedef struct -{ +struct ALDEVICEINFO { std::string strDeviceName; int iMajorVersion; int iMinorVersion; unsigned int uiSourceCount; std::vector *pvstrExtensions; bool bSelected; -} ALDEVICEINFO, *LPALDEVICEINFO; + + ALDEVICEINFO() : iMajorVersion(0), iMinorVersion(0), uiSourceCount(0), pvstrExtensions(NULL), bSelected(false) + { + } +}; + +typedef ALDEVICEINFO *LPALDEVICEINFO; class ALDeviceList { -- cgit v1.2.3 From f92770f74affa700abcec27f872b2627054f27b6 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 24 May 2020 01:44:10 +0300 Subject: Optimize ALDeviceList --- src/audio/oal/aldlist.cpp | 108 +++++++++++++++++----------------------------- src/audio/oal/aldlist.h | 39 +++++++++++------ 2 files changed, 66 insertions(+), 81 deletions(-) (limited to 'src/audio/oal') diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 9834ffb4..3e86b1d7 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -41,8 +41,7 @@ ALDeviceList::ALDeviceList() const char *actualDeviceName; // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support - vDeviceInfo.empty(); - vDeviceInfo.reserve(10); + nNumOfDevices = 0; defaultDeviceIndex = 0; @@ -64,7 +63,7 @@ ALDeviceList::ALDeviceList() // if new actual device name isn't already in the list, then add it... actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); bool bNewName = true; - for (int i = 0; i < GetNumDevices(); i++) { + for (unsigned int i = 0; i < GetNumDevices(); i++) { if (strcmp(GetDeviceName(i), actualDeviceName) == 0) { bNewName = false; } @@ -76,39 +75,37 @@ ALDeviceList::ALDeviceList() alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); - ALDeviceInfo.pvstrExtensions = new std::vector; - // Check for ALC Extensions if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_CAPTURE"); + ALDeviceInfo.Extensions |= ADEXT_EXT_CAPTURE; if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_EFX"); + ALDeviceInfo.Extensions |= ADEXT_EXT_EFX; // Check for AL Extensions if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_OFFSET"); + ALDeviceInfo.Extensions |= ADEXT_EXT_OFFSET; if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_LINEAR_DISTANCE"); + ALDeviceInfo.Extensions |= ADEXT_EXT_LINEAR_DISTANCE; if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_EXPONENT_DISTANCE"); + ALDeviceInfo.Extensions |= ADEXT_EXT_EXPONENT_DISTANCE; if (alIsExtensionPresent("EAX2.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX2.0"); + ALDeviceInfo.Extensions |= ADEXT_EAX2; if (alIsExtensionPresent("EAX3.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX3.0"); + ALDeviceInfo.Extensions |= ADEXT_EAX3; if (alIsExtensionPresent("EAX4.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX4.0"); + ALDeviceInfo.Extensions |= ADEXT_EAX4; if (alIsExtensionPresent("EAX5.0") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX5.0"); + ALDeviceInfo.Extensions |= ADEXT_EAX5; if (alIsExtensionPresent("EAX-RAM") == AL_TRUE) - ALDeviceInfo.pvstrExtensions->push_back("EAX-RAM"); + ALDeviceInfo.Extensions |= ADEXT_EAX_RAM; // Get Source Count ALDeviceInfo.uiSourceCount = GetMaxNumSources(); - vDeviceInfo.push_back(ALDeviceInfo); + aDeviceInfo[nNumOfDevices++] = ALDeviceInfo; } alcMakeContextCurrent(NULL); alcDestroyContext(context); @@ -128,31 +125,23 @@ ALDeviceList::ALDeviceList() */ ALDeviceList::~ALDeviceList() { - for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { - if (vDeviceInfo[i].pvstrExtensions) { - vDeviceInfo[i].pvstrExtensions->empty(); - delete vDeviceInfo[i].pvstrExtensions; - } - } - - vDeviceInfo.empty(); } /* * Returns the number of devices in the complete device list */ -int ALDeviceList::GetNumDevices() +unsigned int ALDeviceList::GetNumDevices() { - return (int)vDeviceInfo.size(); + return nNumOfDevices; } /* * Returns the device name at an index in the complete device list */ -char * ALDeviceList::GetDeviceName(int index) +const char * ALDeviceList::GetDeviceName(unsigned int index) { if (index < GetNumDevices()) - return (char *)vDeviceInfo[index].strDeviceName.c_str(); + return aDeviceInfo[index].strDeviceName; else return NULL; } @@ -160,13 +149,13 @@ char * ALDeviceList::GetDeviceName(int index) /* * Returns the major and minor version numbers for a device at a specified index in the complete list */ -void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor) +void ALDeviceList::GetDeviceVersion(unsigned int index, int *major, int *minor) { if (index < GetNumDevices()) { if (major) - *major = vDeviceInfo[index].iMajorVersion; + *major = aDeviceInfo[index].iMajorVersion; if (minor) - *minor = vDeviceInfo[index].iMinorVersion; + *minor = aDeviceInfo[index].iMinorVersion; } return; } @@ -174,10 +163,10 @@ void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor) /* * Returns the maximum number of Sources that can be generate on the given device */ -unsigned int ALDeviceList::GetMaxNumSources(int index) +unsigned int ALDeviceList::GetMaxNumSources(unsigned int index) { if (index < GetNumDevices()) - return vDeviceInfo[index].uiSourceCount; + return aDeviceInfo[index].uiSourceCount; else return 0; } @@ -185,20 +174,9 @@ unsigned int ALDeviceList::GetMaxNumSources(int index) /* * Checks if the extension is supported on the given device */ -bool ALDeviceList::IsExtensionSupported(int index, const char *szExtName) +bool ALDeviceList::IsExtensionSupported(int index, unsigned short ext) { - bool bReturn = false; - - if (index < GetNumDevices()) { - for (unsigned int i = 0; i < vDeviceInfo[index].pvstrExtensions->size(); i++) { - if (!_stricmp(vDeviceInfo[index].pvstrExtensions->at(i).c_str(), szExtName)) { - bReturn = true; - break; - } - } - } - - return bReturn; + return !!(aDeviceInfo[index].Extensions & ext); } /* @@ -215,10 +193,10 @@ int ALDeviceList::GetDefaultDevice() void ALDeviceList::FilterDevicesMinVer(int major, int minor) { int dMajor, dMinor; - for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + for (unsigned int i = 0; i < nNumOfDevices; i++) { GetDeviceVersion(i, &dMajor, &dMinor); if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) { - vDeviceInfo[i].bSelected = false; + aDeviceInfo[i].bSelected = false; } } } @@ -229,10 +207,10 @@ void ALDeviceList::FilterDevicesMinVer(int major, int minor) void ALDeviceList::FilterDevicesMaxVer(int major, int minor) { int dMajor, dMinor; - for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + for (unsigned int i = 0; i < nNumOfDevices; i++) { GetDeviceVersion(i, &dMajor, &dMinor); if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) { - vDeviceInfo[i].bSelected = false; + aDeviceInfo[i].bSelected = false; } } } @@ -240,20 +218,12 @@ void ALDeviceList::FilterDevicesMaxVer(int major, int minor) /* * Deselects device which don't support the given extension name */ -void ALDeviceList::FilterDevicesExtension(char *szExtName) +void +ALDeviceList::FilterDevicesExtension(unsigned short ext) { - bool bFound; - - for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { - bFound = false; - for (unsigned int j = 0; j < vDeviceInfo[i].pvstrExtensions->size(); j++) { - if (!_stricmp(vDeviceInfo[i].pvstrExtensions->at(j).c_str(), szExtName)) { - bFound = true; - break; - } - } - if (!bFound) - vDeviceInfo[i].bSelected = false; + for (unsigned int i = 0; i < nNumOfDevices; i++) { + if (!IsExtensionSupported(i, ext)) + aDeviceInfo[i].bSelected = false; } } @@ -262,8 +232,8 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName) */ void ALDeviceList::ResetFilters() { - for (int i = 0; i < GetNumDevices(); i++) { - vDeviceInfo[i].bSelected = true; + for (unsigned int i = 0; i < GetNumDevices(); i++) { + aDeviceInfo[i].bSelected = true; } filterIndex = 0; } @@ -273,10 +243,10 @@ void ALDeviceList::ResetFilters() */ int ALDeviceList::GetFirstFilteredDevice() { - int i; + unsigned int i; for (i = 0; i < GetNumDevices(); i++) { - if (vDeviceInfo[i].bSelected == true) { + if (aDeviceInfo[i].bSelected == true) { break; } } @@ -289,10 +259,10 @@ int ALDeviceList::GetFirstFilteredDevice() */ int ALDeviceList::GetNextFilteredDevice() { - int i; + unsigned int i; for (i = filterIndex; i < GetNumDevices(); i++) { - if (vDeviceInfo[i].bSelected == true) { + if (aDeviceInfo[i].bSelected == true) { break; } } diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h index 3afa6bfe..417bd314 100644 --- a/src/audio/oal/aldlist.h +++ b/src/audio/oal/aldlist.h @@ -5,19 +5,33 @@ #ifdef AUDIO_OAL #pragma warning(disable: 4786) //disable warning "identifier was truncated to '255' characters in the browser information" -#include -#include + +enum +{ + ADEXT_EXT_CAPTURE = (1 << 0), + ADEXT_EXT_EFX = (1 << 1), + ADEXT_EXT_OFFSET = (1 << 2), + ADEXT_EXT_LINEAR_DISTANCE = (1 << 3), + ADEXT_EXT_EXPONENT_DISTANCE = (1 << 4), + ADEXT_EAX2 = (1 << 5), + ADEXT_EAX3 = (1 << 6), + ADEXT_EAX4 = (1 << 7), + ADEXT_EAX5 = (1 << 8), + ADEXT_EAX_RAM = (1 << 9), +}; struct ALDEVICEINFO { - std::string strDeviceName; + const char *strDeviceName; int iMajorVersion; int iMinorVersion; unsigned int uiSourceCount; - std::vector *pvstrExtensions; + unsigned short Extensions; bool bSelected; - ALDEVICEINFO() : iMajorVersion(0), iMinorVersion(0), uiSourceCount(0), pvstrExtensions(NULL), bSelected(false) + ALDEVICEINFO() : iMajorVersion(0), iMinorVersion(0), uiSourceCount(0), bSelected(false) { + strDeviceName = NULL; + Extensions = 0; } }; @@ -26,22 +40,23 @@ typedef ALDEVICEINFO *LPALDEVICEINFO; class ALDeviceList { private: - std::vector vDeviceInfo; + ALDEVICEINFO aDeviceInfo[64]; + unsigned int nNumOfDevices; int defaultDeviceIndex; int filterIndex; public: ALDeviceList (); ~ALDeviceList (); - int GetNumDevices(); - char *GetDeviceName(int index); - void GetDeviceVersion(int index, int *major, int *minor); - unsigned int GetMaxNumSources(int index); - bool IsExtensionSupported(int index, const char *szExtName); + unsigned int GetNumDevices(); + const char *GetDeviceName(unsigned int index); + void GetDeviceVersion(unsigned int index, int *major, int *minor); + unsigned int GetMaxNumSources(unsigned int index); + bool IsExtensionSupported(int index, unsigned short ext); int GetDefaultDevice(); void FilterDevicesMinVer(int major, int minor); void FilterDevicesMaxVer(int major, int minor); - void FilterDevicesExtension(char *szExtName); + void FilterDevicesExtension(unsigned short ext); void ResetFilters(); int GetFirstFilteredDevice(); int GetNextFilteredDevice(); -- cgit v1.2.3