diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-13 16:55:12 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-13 16:55:12 +0200 |
commit | d4265884966496f3e1ab64cb61097555e43a549c (patch) | |
tree | 960d3b27ea4f34958599bfc26fe3dc07e34f03ba /src/audio | |
parent | ped attractor: start (diff) | |
parent | Merge branch 'master' into miami (diff) | |
download | re3-d4265884966496f3e1ab64cb61097555e43a549c.tar re3-d4265884966496f3e1ab64cb61097555e43a549c.tar.gz re3-d4265884966496f3e1ab64cb61097555e43a549c.tar.bz2 re3-d4265884966496f3e1ab64cb61097555e43a549c.tar.lz re3-d4265884966496f3e1ab64cb61097555e43a549c.tar.xz re3-d4265884966496f3e1ab64cb61097555e43a549c.tar.zst re3-d4265884966496f3e1ab64cb61097555e43a549c.zip |
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/DMAudio.cpp | 1 | ||||
-rw-r--r-- | src/audio/oal/aldlist.cpp | 14 | ||||
-rw-r--r-- | src/audio/oal/aldlist.h | 4 | ||||
-rw-r--r-- | src/audio/oal/channel.cpp | 6 | ||||
-rw-r--r-- | src/audio/oal/stream.cpp | 27 | ||||
-rw-r--r-- | src/audio/sampman_oal.cpp | 22 |
6 files changed, 53 insertions, 21 deletions
diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index f1b9707b..888081b7 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -6,6 +6,7 @@ #include "AudioScriptObject.h" #include "sampman.h" #include "Text.h" +#include "crossplatform.h" cDMAudio DMAudio; diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 2c2f13a8..458b7c80 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -23,6 +23,12 @@ */ #include "aldlist.h" + +#ifndef _WIN32 +#define _stricmp strcasecmp +#define _strnicmp strncasecmp +#endif + #ifdef AUDIO_OAL /* * Init call @@ -47,7 +53,7 @@ ALDeviceList::ALDeviceList() index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) - while (*devices != NULL) { + while (*devices != '\0') { if (strcmp(defaultDeviceName, devices) == 0) { defaultDeviceIndex = index; } @@ -67,7 +73,7 @@ ALDeviceList::ALDeviceList() if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); ALDeviceInfo.bSelected = true; - ALDeviceInfo.strDeviceName = std::string(actualDeviceName, strlen(actualDeviceName)); + ALDeviceInfo.strDeviceName.assign(actualDeviceName, strlen(actualDeviceName)); alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); @@ -180,7 +186,7 @@ unsigned int ALDeviceList::GetMaxNumSources(int index) /* * Checks if the extension is supported on the given device */ -bool ALDeviceList::IsExtensionSupported(int index, char *szExtName) +bool ALDeviceList::IsExtensionSupported(int index, const char *szExtName) { bool bReturn = false; @@ -326,4 +332,4 @@ unsigned int ALDeviceList::GetMaxNumSources() return iSourceCount; } -#endif
\ No newline at end of file +#endif diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h index b8f1b31a..694c9d01 100644 --- a/src/audio/oal/aldlist.h +++ b/src/audio/oal/aldlist.h @@ -32,7 +32,7 @@ public: char *GetDeviceName(int index); void GetDeviceVersion(int index, int *major, int *minor); unsigned int GetMaxNumSources(int index); - bool IsExtensionSupported(int index, char *szExtName); + bool IsExtensionSupported(int index, const char *szExtName); int GetDefaultDevice(); void FilterDevicesMinVer(int major, int minor); void FilterDevicesMaxVer(int major, int minor); @@ -46,4 +46,4 @@ private: }; #endif -#endif // ALDEVICELIST_H
\ No newline at end of file +#endif // ALDEVICELIST_H diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 7742a06a..6fe1d856 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -4,6 +4,10 @@ #include "common.h" #include "sampman.h" +#ifndef _WIN32 +#include <float.h> +#endif + extern bool IsFXSupported(); CChannel::CChannel() @@ -207,4 +211,4 @@ void CChannel::UpdateReverb(ALuint slot) alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); } -#endif
\ No newline at end of file +#endif diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 9bca0546..5a9c7d7d 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -4,13 +4,15 @@ #include "common.h" #include "sampman.h" -typedef long ssize_t; - #include <sndfile.h> #include <mpg123.h> - +#ifdef _WIN32 +typedef long ssize_t; #pragma comment( lib, "libsndfile-1.lib" ) #pragma comment( lib, "libmpg123.lib" ) +#else +#include "crossplatform.h" +#endif class CSndFile : public IDecoder { @@ -192,7 +194,22 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF m_nPosBeforeReset(0) { - strcpy(m_aFilename, filename); +// Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) +#if !defined(_WIN32) + FILE *test = fopen(filename, "r"); + if (!test) { + char *r = (char*)alloca(strlen(filename) + 2); + if (casepath(filename, r)) + { + strcpy(m_aFilename, r); + } + } else { + fclose(test); +#else + { +#endif + strcpy(m_aFilename, filename); + } DEV("Stream %s\n", m_aFilename); @@ -517,4 +534,4 @@ void CStream::ProviderTerm() ClearBuffers(); } -#endif
\ No newline at end of file +#endif diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index bbaeae4c..64b763ec 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -5,16 +5,18 @@ #include "sampman.h" #include <time.h> -#include <io.h> #include "eax.h" #include "eax-util.h" +#ifdef _WIN32 +#include <io.h> #include <AL/al.h> #include <AL/alc.h> #include <AL/alext.h> #include <AL/efx.h> #include <AL/efx-presets.h> +#endif #include "oal/oal_utils.h" #include "oal/aldlist.h" @@ -31,7 +33,9 @@ //TODO: loop count //TODO: mp3 player +#ifdef _WIN32 #pragma comment( lib, "OpenAL32.lib" ) +#endif cSampleManager SampleManager; bool _bSampmanInitialised = false; @@ -61,15 +65,15 @@ struct int defaultProvider; -char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; -char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; +char SampleBankDescFilename[] = "audio/sfx.SDT"; +char SampleBankDataFilename[] = "audio/sfx.RAW"; FILE *fpSampleDescHandle; FILE *fpSampleDataHandle; bool bSampleBankLoaded [MAX_SAMPLEBANKS]; int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; int32 nSampleBankSize [MAX_SAMPLEBANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +uintptr nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; int32 _nSampleDataEndOffset; int32 nPedSlotSfx [MAX_PEDSFX]; @@ -88,7 +92,7 @@ struct { ALuint buffer; ALuint timer; - + bool IsEmpty() { return timer == 0; } void Set(ALuint buf) { buffer = buf; } void Wait() { timer = 10000; } @@ -573,7 +577,7 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); + nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (uintptr)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != NULL); if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == NULL ) @@ -582,7 +586,7 @@ cSampleManager::Initialise(void) return false; } - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != NULL); } @@ -985,7 +989,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( !IsSampleBankLoaded(nBank) ) return false; - int32 addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; + uintptr addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; if ( ALBuffers[nSfx].IsEmpty() ) { @@ -1401,4 +1405,4 @@ cSampleManager::InitialiseSampleBanks(void) return true; } -#endif
\ No newline at end of file +#endif |