diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-05-22 12:08:26 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-06-24 20:34:32 +0200 |
commit | 5bcdb933a78abb2b9b8d6648d17502240bd9fd29 (patch) | |
tree | df31ee5fefd2ee7716b9ba01cc0062361520a655 /src/audio/sampman_oal.cpp | |
parent | Fix C3dMarkers::PlaceMarker calls in Radar (diff) | |
download | re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar.gz re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar.bz2 re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar.lz re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar.xz re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.tar.zst re3-5bcdb933a78abb2b9b8d6648d17502240bd9fd29.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/sampman_oal.cpp | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 5a300cff..e74fac82 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -48,7 +48,7 @@ //TODO: max channels cSampleManager SampleManager; -bool _bSampmanInitialised = false; +bool8 _bSampmanInitialised = FALSE; uint32 BankStartOffset[MAX_SFX_BANKS]; @@ -84,7 +84,7 @@ OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; #endif -bool bSampleBankLoaded [MAX_SFX_BANKS]; +bool8 bSampleBankLoaded [MAX_SFX_BANKS]; int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; int32 nSampleBankSize [MAX_SFX_BANKS]; uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; @@ -121,7 +121,7 @@ uint8 nStreamVolume[MAX_STREAMS]; uint8 nStreamLoopedFlag[MAX_STREAMS]; uint32 _CurMP3Index; int32 _CurMP3Pos; -bool _bIsMp3Active; +bool8 _bIsMp3Active; /////////////////////////////////////////////////////////////// // Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS EAXLISTENERPROPERTIES StartEAX3 = @@ -266,11 +266,11 @@ release_existing() DEV("release_existing()\n"); } -static bool +static bool8 set_new_provider(int index) { if ( curprovider == index ) - return true; + return TRUE; curprovider = index; @@ -302,7 +302,7 @@ set_new_provider(int index) { curprovider=-1; release_existing(); - return false; + return FALSE; } alListenerf (AL_GAIN, 1.0f); @@ -383,13 +383,13 @@ set_new_provider(int index) aChannel[i].SetReverbMix(ALEffectSlot, 0.0f); } - return true; + return TRUE; } - return false; + return FALSE; } -static bool +static bool8 IsThisTrackAt16KHz(uint32 track) { return track == STREAMED_SOUND_RADIO_KCHAT || track == STREAMED_SOUND_RADIO_VCPR || track == STREAMED_SOUND_RADIO_POLICE; @@ -482,13 +482,13 @@ cSampleManager::AutoDetect3DProviders() return -1; } -static bool +static bool8 _ResolveLink(char const *path, char *out) { #ifdef _WIN32 size_t len = strlen(path); if (len < 4 || strcmp(&path[len - 4], ".lnk") != 0) - return false; + return FALSE; IShellLink* psl; WIN32_FIND_DATA fd; @@ -523,7 +523,7 @@ _ResolveLink(char const *path, char *out) ppf->Release(); psl->Release(); #endif - return true; + return TRUE; } } } @@ -533,31 +533,31 @@ _ResolveLink(char const *path, char *out) psl->Release(); } - return false; + return FALSE; #else struct stat sb; if (lstat(path, &sb) == -1) { perror("lstat: "); - return false; + return FALSE; } if (S_ISLNK(sb.st_mode)) { char* linkname = (char*)alloca(sb.st_size + 1); if (linkname == NULL) { fprintf(stderr, "insufficient memory\n"); - return false; + return FALSE; } if (readlink(path, linkname, sb.st_size + 1) < 0) { perror("readlink: "); - return false; + return FALSE; } linkname[sb.st_size] = '\0'; strcpy(out, linkname); - return true; + return TRUE; } else { - return false; + return FALSE; } #endif } @@ -566,8 +566,8 @@ static void _FindMP3s(void) { tMP3Entry *pList; - bool bShortcut; - bool bInitFirstEntry; + bool8 bShortcut; + bool8 bInitFirstEntry; HANDLE hFind; char path[MAX_PATH]; char filepath[MAX_PATH*2]; @@ -610,9 +610,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else - bShortcut = false; + bShortcut = FALSE; aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); @@ -652,7 +652,7 @@ _FindMP3s(void) _pMP3List->pLinkPath = NULL; } - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -660,10 +660,10 @@ _FindMP3s(void) OutputDebugString(filepath); - bInitFirstEntry = true; + bInitFirstEntry = TRUE; } - while ( true ) + while ( TRUE ) { if ( !FindNextFile(hFind, &fd) ) break; @@ -681,9 +681,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else { - bShortcut = false; + bShortcut = FALSE; if (filepathlen > MAX_PATH) { continue; } @@ -722,7 +722,7 @@ _FindMP3s(void) pList = _pMP3List; - bInitFirstEntry = false; + bInitFirstEntry = FALSE; } else { @@ -744,9 +744,9 @@ _FindMP3s(void) { OutputDebugString("Resolving Link"); OutputDebugString(filepath); - bShortcut = true; + bShortcut = TRUE; } else - bShortcut = false; + bShortcut = FALSE; aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); @@ -858,7 +858,7 @@ _GetMP3EntryByIndex(uint32 idx) return NULL; } -static inline bool +static inline bool8 _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) { _CurMP3Index = 0; @@ -871,7 +871,7 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) *pPosition -= (*pEntry)->nTrackStreamPos; _CurMP3Pos = *pPosition; - return true; + return TRUE; } _CurMP3Index++; @@ -882,10 +882,10 @@ _GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) _CurMP3Pos = 0; _CurMP3Index = 0; - return false; + return FALSE; } -bool +bool8 cSampleManager::IsMP3RadioChannelAvailable(void) { return nNumMP3s != 0; @@ -911,11 +911,11 @@ void cSampleManager::ReacquireDigitalHandle(void) } } -bool +bool8 cSampleManager::Initialise(void) { if ( _bSampmanInitialised ) - return true; + return TRUE; EFXInit(); CStream::Initialise(); @@ -960,7 +960,7 @@ cSampleManager::Initialise(void) for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) { - bSampleBankLoaded[i] = false; + bSampleBankLoaded[i] = FALSE; nSampleBankDiscStartOffset[i] = 0; nSampleBankSize[i] = 0; nSampleBankMemoryStartAddress[i] = 0; @@ -1031,7 +1031,7 @@ cSampleManager::Initialise(void) if ( !InitialiseSampleBanks() ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); @@ -1040,7 +1040,7 @@ cSampleManager::Initialise(void) if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) { Terminate(); - return false; + return FALSE; } nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); @@ -1059,7 +1059,7 @@ cSampleManager::Initialise(void) } { - _bSampmanInitialised = true; + _bSampmanInitialised = TRUE; if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) { @@ -1068,7 +1068,7 @@ cSampleManager::Initialise(void) else { Terminate(); - return false; + return FALSE; } } @@ -1091,13 +1091,13 @@ cSampleManager::Initialise(void) time_t t = time(NULL); tm *localtm; - bool bUseRandomTable; + bool8 bUseRandomTable; if ( t == -1 ) - bUseRandomTable = true; + bUseRandomTable = TRUE; else { - bUseRandomTable = false; + bUseRandomTable = FALSE; localtm = localtime(&t); } @@ -1129,10 +1129,10 @@ cSampleManager::Initialise(void) else _CurMP3Pos = 0; - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } - return true; + return TRUE; } void @@ -1166,12 +1166,12 @@ cSampleManager::Terminate(void) nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } - _bSampmanInitialised = false; + _bSampmanInitialised = FALSE; } -bool cSampleManager::CheckForAnAudioFileOnCD(void) +bool8 cSampleManager::CheckForAnAudioFileOnCD(void) { - return true; + return TRUE; } char cSampleManager::GetCDAudioDriveLetter(void) @@ -1228,24 +1228,24 @@ cSampleManager::SetMusicFadeVolume(uint8 nVolume) } void -cSampleManager::SetMonoMode(uint8 nMode) +cSampleManager::SetMonoMode(bool8 nMode) { m_nMonoMode = nMode; } -bool +bool8 cSampleManager::LoadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; if ( MusicManager.IsInitialised() && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE && nBank != SFX_BANK_0 ) { - return false; + return FALSE; } #ifdef OPUS_SFX @@ -1264,14 +1264,14 @@ cSampleManager::LoadSampleBank(uint8 nBank) } #else if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) - return false; + return FALSE; #endif - bSampleBankLoaded[nBank] = true; + bSampleBankLoaded[nBank] = TRUE; - return true; + return TRUE; } void @@ -1279,10 +1279,10 @@ cSampleManager::UnloadSampleBank(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); - bSampleBankLoaded[nBank] = false; + bSampleBankLoaded[nBank] = FALSE; } -bool +bool8 cSampleManager::IsSampleBankLoaded(uint8 nBank) { ASSERT( nBank < MAX_SFX_BANKS); @@ -1290,7 +1290,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) return bSampleBankLoaded[nBank]; } -bool +bool8 cSampleManager::IsPedCommentLoaded(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); @@ -1305,10 +1305,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment) slot += ARRAY_SIZE(nPedSlotSfx); #endif if ( nComment == nPedSlotSfx[slot] ) - return true; + return TRUE; } - return false; + return FALSE; } @@ -1331,13 +1331,13 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment) return -1; } -bool +bool8 cSampleManager::LoadPedComment(uint32 nComment) { ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); if ( CTimer::GetIsCodePaused() ) - return false; + return FALSE; // no talking peds during cutsenes or the game end if ( MusicManager.IsInitialised() ) @@ -1346,7 +1346,7 @@ cSampleManager::LoadPedComment(uint32 nComment) { case MUSICMODE_CUTSCENE: { - return false; + return FALSE; break; } @@ -1361,17 +1361,17 @@ cSampleManager::LoadPedComment(uint32 nComment) int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), samplesSize, NULL); if (size <= 0) { - return false; + return FALSE; } samplesRead += size * 2; samplesSize -= size; } #else if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) - return false; + return FALSE; if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) - return false; + return FALSE; #endif nPedSlotSfx[nCurrentPedSlot] = nComment; @@ -1379,7 +1379,7 @@ cSampleManager::LoadPedComment(uint32 nComment) if ( ++nCurrentPedSlot >= MAX_PEDSFX ) nCurrentPedSlot = 0; - return true; + return TRUE; } int32 @@ -1422,13 +1422,13 @@ cSampleManager::GetSampleLength(uint32 nSample) return m_aSamples[nSample].nSize / sizeof(uint16); } -bool cSampleManager::UpdateReverb(void) +bool8 cSampleManager::UpdateReverb(void) { if ( !usingEAX && !_usingEFX ) - return false; + return FALSE; if ( AudioManager.GetFrameCounter() & 15 ) - return false; + return FALSE; float fRatio = 0.0f; @@ -1449,7 +1449,7 @@ bool cSampleManager::UpdateReverb(void) fRatio = clamp(fRatio, 0.0f, 0.6f); if ( fRatio == _fPrevEaxRatioDestination ) - return false; + return FALSE; #ifdef JUICY_OAL if ( usingEAX3 || _usingEFX ) @@ -1486,11 +1486,11 @@ bool cSampleManager::UpdateReverb(void) _fPrevEaxRatioDestination = fRatio; - return true; + return TRUE; } void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +cSampleManager::SetChannelReverbFlag(uint32 nChannel, bool8 nReverbFlag) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1500,7 +1500,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) { alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); - if ( nReverbFlag != 0 ) + if ( nReverbFlag != FALSE ) aChannel[nChannel].SetReverbMix(ALEffectSlot, _fEffectsLevel); else aChannel[nChannel].SetReverbMix(ALEffectSlot, 0.0f); @@ -1508,7 +1508,7 @@ cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) } } -bool +bool8 cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1518,14 +1518,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) if ( nSfx < SAMPLEBANK_MAX ) { if ( !IsSampleBankLoaded(nBank) ) - return false; + return FALSE; addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { if ( !IsPedCommentLoaded(nSfx) ) - return false; + return FALSE; int32 slot = _GetPedCommentSlot(nSfx); addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); @@ -1543,10 +1543,10 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); aChannel[nChannel].SetLoopPoints (0, -1); aChannel[nChannel].SetPitch (1.0f); - return true; + return TRUE; } - return false; + return FALSE; } void @@ -1649,7 +1649,7 @@ cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) aChannel[nChannel].SetLoopCount(nLoopCount); } -bool +bool8 cSampleManager::GetChannelUsedFlag(uint32 nChannel) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); @@ -1703,7 +1703,7 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream) } void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +cSampleManager::PauseStream(bool8 nPauseFlag, uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); @@ -1711,7 +1711,7 @@ cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) if ( stream ) { - stream->SetPause(nPauseFlag != 0); + stream->SetPause(nPauseFlag != FALSE); } } @@ -1731,7 +1731,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) } } -bool +bool8 cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) { int i = 0; @@ -1739,7 +1739,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) char filename[MAX_PATH]; if ( nFile >= TOTAL_STREAMED_SOUNDS ) - return false; + return FALSE; if ( aStream[nStream] ) { @@ -1768,18 +1768,18 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) if (stream->Setup()) { stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); - nStreamLoopedFlag[nStream] = true; + nStreamLoopedFlag[nStream] = TRUE; if (position != 0) stream->SetPosMS(position); stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } else { @@ -1798,8 +1798,8 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream]->Start(); - _bIsMp3Active = true; - return true; + _bIsMp3Active = TRUE; + return TRUE; } else { delete aStream[nStream]; aStream[nStream] = NULL; @@ -1827,18 +1827,18 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) if (stream->Setup()) { stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); - nStreamLoopedFlag[nStream] = true; + nStreamLoopedFlag[nStream] = TRUE; if (position != 0) stream->SetPosMS(position); stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } } if (mp3->pLinkPath != NULL) @@ -1853,9 +1853,9 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) if (aStream[nStream]->Setup()) { aStream[nStream]->Start(); #ifdef FIX_BUGS - _bIsMp3Active = true; + _bIsMp3Active = TRUE; #endif - return true; + return TRUE; } else { delete aStream[nStream]; aStream[nStream] = NULL; @@ -1876,18 +1876,18 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) if ( stream->Setup() ) { stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); - nStreamLoopedFlag[nStream] = true; + nStreamLoopedFlag[nStream] = TRUE; if (position != 0) stream->SetPosMS(position); stream->Start(); - return true; + return TRUE; } else { delete stream; aStream[nStream] = NULL; } - return false; + return FALSE; } void @@ -1903,7 +1903,7 @@ cSampleManager::StopStreamedFile(uint8 nStream) aStream[nStream] = NULL; if ( nStream == 0 ) - _bIsMp3Active = false; + _bIsMp3Active = FALSE; } } @@ -1937,7 +1937,7 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) } void -cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) +cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, bool8 nEffectFlag, uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); @@ -1980,7 +1980,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream) return nStreamLength[nStream]; } -bool +bool8 cSampleManager::IsStreamPlaying(uint8 nStream) { ASSERT( nStream < MAX_STREAMS ); @@ -1990,10 +1990,10 @@ cSampleManager::IsStreamPlaying(uint8 nStream) if ( stream ) { if ( stream->IsPlaying() ) - return true; + return TRUE; } - return false; + return FALSE; } void @@ -2014,14 +2014,14 @@ cSampleManager::Service(void) } } -bool +bool8 cSampleManager::InitialiseSampleBanks(void) { int32 nBank = SFX_BANK_0; fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) - return false; + return FALSE; #ifndef OPUS_SFX fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) @@ -2029,7 +2029,7 @@ cSampleManager::InitialiseSampleBanks(void) fclose(fpSampleDescHandle); fpSampleDescHandle = NULL; - return false; + return FALSE; } fseek(fpSampleDataHandle, 0, SEEK_END); @@ -2061,7 +2061,7 @@ cSampleManager::InitialiseSampleBanks(void) nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; - return true; + return TRUE; } void |