summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-09-02 18:22:50 +0200
committerSergeanur <s.anureev@yandex.ua>2021-09-02 18:22:50 +0200
commita16fcd8d6a79e433c1c6e73d540f1bbe27e14164 (patch)
tree99b17cfb4a55ad82391431451c9660f313ea3e61
parentAudio: small refactoring (diff)
downloadre3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar.gz
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar.bz2
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar.lz
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar.xz
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.tar.zst
re3-a16fcd8d6a79e433c1c6e73d540f1bbe27e14164.zip
-rw-r--r--src/audio/AudioLogic.cpp28
-rw-r--r--src/audio/AudioManager.h6
-rw-r--r--src/audio/sampman.h6
-rw-r--r--src/audio/sampman_miles.cpp43
-rw-r--r--src/audio/sampman_null.cpp12
-rw-r--r--src/audio/sampman_oal.cpp42
6 files changed, 80 insertions, 57 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index 54d7ad59..35ca09cd 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -5321,7 +5321,7 @@ cAudioManager::SetupPedComments(cPedParams &params, uint16 sound)
else
Vol = PED_COMMENT_VOLUME_BEHIND_WALL;
m_sQueueSample.m_nVolume = ComputeVolume(Vol, maxDist, m_sQueueSample.m_fDistance);
- pedComment.m_nProcess = 10;
+ pedComment.m_nLoadingTimeout = 10;
if (m_sQueueSample.m_nVolume > 0) {
pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex;
pedComment.m_vecPos = m_sQueueSample.m_vecPos;
@@ -7909,7 +7909,7 @@ cAudioManager::DebugPlayPedComment(int32 sound)
tPedComment pedComment;
pedComment.m_nSampleIndex = sound;
- pedComment.m_nProcess = 10;
+ pedComment.m_nLoadingTimeout = 10;
pedComment.m_nEntityIndex = 0;
pedComment.m_fDistance = 0.0f;
pedComment.m_nVolume = 99;
@@ -7982,12 +7982,12 @@ cPedComments::Process()
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
if(m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex ==
prevSamples[(counter + 1 + i) % ARRAY_SIZE(prevSamples)]) {
- m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
+ m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nLoadingTimeout = -1;
goto PedCommentAlreadyAdded;
}
}
#if defined(GTA_PS2) || defined(FIX_BUGS)
- bool8 IsLoadedResult;
+ uint8 IsLoadedResult;
sampleIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex;
if (sampleIndex >= PLAYER_COMMENTS_START && sampleIndex <= PLAYER_COMMENTS_END) {
IsLoadedResult = SampleManager.IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, sampleIndex);
@@ -7996,11 +7996,11 @@ cPedComments::Process()
IsLoadedResult = SampleManager.IsPedCommentLoaded(sampleIndex);
bIsPlayerComment = FALSE;
}
- switch(IsLoadedResult) { // yes, this was a switch
+ switch(IsLoadedResult) {
#else
- switch(SampleManager.IsPedCommentLoaded(sampleIndex)) { // yes, this was a switch
+ switch(SampleManager.IsPedCommentLoaded(sampleIndex)) {
#endif
- case FALSE:
+ case LOADING_STATUS_NOT_LOADED:
#if defined(GTA_PC) && !defined(FIX_BUGS)
if(!m_bDelay)
#endif
@@ -8011,7 +8011,7 @@ cPedComments::Process()
#endif
SampleManager.LoadPedComment(sampleIndex);
break;
- case TRUE:
+ case LOADING_STATUS_LOADED:
AudioManager.m_sQueueSample.m_nEntityIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nEntityIndex;
AudioManager.m_sQueueSample.m_nCounter = 0;
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
@@ -8065,7 +8065,7 @@ cPedComments::Process()
if (CTimer::GetIsSlowMotionActive())
AudioManager.m_sQueueSample.m_nFrequency >>= 1;
#endif
- m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
+ m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nLoadingTimeout = -1;
prevSamples[counter++] = sampleIndex;
if(counter == 10) counter = 0;
AudioManager.AddSampleToRequestedQueue();
@@ -8074,8 +8074,8 @@ cPedComments::Process()
m_bDelay = TRUE;
#endif
break;
- default:
- break;
+ case LOADING_STATUS_LOADING: break;
+ default: break;
}
}
@@ -8089,8 +8089,8 @@ PedCommentAlreadyAdded:
m_nActiveQueue = 0;
}
for (uint8 i = 0; i < m_nPedCommentCount[queue]; i++) {
- if (m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nProcess > 0) {
- m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nProcess--;
+ if (m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nLoadingTimeout > 0) {
+ m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nLoadingTimeout--;
Add(&m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]]);
}
}
@@ -10116,7 +10116,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED;
nFramesUntilFailedLoad[slot] = 0;
break;
- case LOADING_STATUS_FAILED:
+ case LOADING_STATUS_LOADING:
if (++nFramesUntilFailedLoad[slot] >= 120) {
nFramesForPretendPlaying[slot] = 0;
g_bMissionAudioLoadFailed[slot] = TRUE;
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 1312826b..49edcfec 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -88,7 +88,7 @@ public:
CVector m_vecPos;
float m_fDistance;
uint8 m_nVolume;
- int8 m_nProcess;
+ int8 m_nLoadingTimeout; // how many iterations we gonna wait until dropping the sample if it's still not loaded (only useful on PS2)
#if defined(EXTERNAL_3D_SOUND) && defined(FIX_BUGS)
uint8 m_nEmittingVolume;
#endif
@@ -112,7 +112,7 @@ public:
{
for (int i = 0; i < NUM_PED_COMMENTS_SLOTS; i++)
for (int j = 0; j < NUM_SOUND_QUEUES; j++) {
- m_aPedCommentQueue[j][i].m_nProcess = -1;
+ m_aPedCommentQueue[j][i].m_nLoadingTimeout = -1;
m_aPedCommentOrderList[j][i] = NUM_PED_COMMENTS_SLOTS;
}
@@ -218,7 +218,7 @@ enum {
#endif
enum PLAY_STATUS { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED };
-enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED };
+enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_LOADING };
class cAudioManager
{
diff --git a/src/audio/sampman.h b/src/audio/sampman.h
index dadaf24d..e585b0d6 100644
--- a/src/audio/sampman.h
+++ b/src/audio/sampman.h
@@ -203,14 +203,14 @@ public:
bool8 LoadSampleBank (uint8 nBank);
void UnloadSampleBank (uint8 nBank);
- bool8 IsSampleBankLoaded(uint8 nBank);
+ int8 IsSampleBankLoaded(uint8 nBank);
#if defined (GTA_PS2) || defined (FIX_BUGS)
- bool8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
+ uint8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
bool8 LoadMissionAudio (uint8 nSlot, uint32 nSample);
#endif
- bool8 IsPedCommentLoaded(uint32 nComment);
+ uint8 IsPedCommentLoaded(uint32 nComment);
bool8 LoadPedComment (uint32 nComment);
int32 GetBankContainingSound(uint32 offset);
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index 1f2973f8..9f8e8a9c 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -29,7 +29,7 @@ char SampleBankDataFilename[] = "AUDIO\\SFX.RAW";
FILE *fpSampleDescHandle;
FILE *fpSampleDataHandle;
-bool8 bSampleBankLoaded [MAX_SFX_BANKS];
+int8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@@ -964,7 +964,7 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{
- bSampleBankLoaded[i] = FALSE;
+ gBankLoaded[i] = LOADING_STATUS_NOT_LOADED;
nSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0;
@@ -1595,7 +1595,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] )
return FALSE;
- bSampleBankLoaded[nBank] = TRUE;
+ gBankLoaded[nBank] = LOADING_STATUS_LOADED;
return TRUE;
}
@@ -1603,22 +1603,22 @@ cSampleManager::LoadSampleBank(uint8 nBank)
void
cSampleManager::UnloadSampleBank(uint8 nBank)
{
- bSampleBankLoaded[nBank] = FALSE;
+ gBankLoaded[nBank] = LOADING_STATUS_NOT_LOADED;
}
-bool8
+int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
- return bSampleBankLoaded[nBank];
+ return gBankLoaded[nBank];
}
#ifdef FIX_BUGS
-bool8
+uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
- return nSample == gPlayerTalkSfx;
+ return nSample == gPlayerTalkSfx ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
}
bool8
@@ -1639,7 +1639,7 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
}
#endif
-bool8
+uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
int8 slot;
@@ -1652,10 +1652,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if ( nComment == nPedSlotSfx[slot] )
- return TRUE;
+ return LOADING_STATUS_LOADED;
}
- return FALSE;
+ return LOADING_STATUS_NOT_LOADED;
}
int32
@@ -1873,12 +1873,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
#endif
else
{
- if ( !IsPedCommentLoaded(nSfx) )
+ int32 i;
+ for ( i = 0; i < _TODOCONST(3); i++ )
+ {
+ int32 slot = nCurrentPedSlot - i - 1;
+#ifdef FIX_BUGS
+ if (slot < 0)
+ slot += ARRAY_SIZE(nPedSlotSfx);
+#endif
+ if ( nSfx == nPedSlotSfx[slot] )
+ {
+ addr = nPedSlotSfxAddr[slot];
+ break;
+ }
+ }
+
+ if (i == _TODOCONST(3))
return FALSE;
-
- int32 slot = _GetPedCommentSlot(nSfx);
-
- addr = nPedSlotSfxAddr[slot];
}
#ifdef EXTERNAL_3D_SOUND
diff --git a/src/audio/sampman_null.cpp b/src/audio/sampman_null.cpp
index f66488b8..2e6c628d 100644
--- a/src/audio/sampman_null.cpp
+++ b/src/audio/sampman_null.cpp
@@ -148,20 +148,20 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
ASSERT( nBank < MAX_SFX_BANKS );
}
-bool8
+int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS );
- return FALSE;
+ return LOADING_STATUS_NOT_LOADED;
}
-bool8
+uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot < MISSION_AUDIO_COUNT);
- return FALSE;
+ return LOADING_STATUS_NOT_LOADED;
}
bool8
@@ -172,12 +172,12 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
return FALSE;
}
-bool8
+uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
- return FALSE;
+ return LOADING_STATUS_NOT_LOADED;
}
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 817d68dd..9cf30832 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -92,7 +92,7 @@ OggOpusFile *fpSampleDataHandle;
#else
FILE *fpSampleDataHandle;
#endif
-bool8 bSampleBankLoaded [MAX_SFX_BANKS];
+int8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@@ -812,7 +812,7 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{
- bSampleBankLoaded[i] = FALSE;
+ gBankLoaded[i] = LOADING_STATUS_NOT_LOADED;
nSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0;
@@ -1250,7 +1250,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] )
return FALSE;
#endif
- bSampleBankLoaded[nBank] = TRUE;
+ gBankLoaded[nBank] = LOADING_STATUS_LOADED;
return TRUE;
}
@@ -1260,24 +1260,24 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS);
- bSampleBankLoaded[nBank] = FALSE;
+ gBankLoaded[nBank] = LOADING_STATUS_NOT_LOADED;
}
-bool8
+int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS);
- return bSampleBankLoaded[nBank];
+ return gBankLoaded[nBank];
}
#ifdef FIX_BUGS
-bool8
+uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
- return nSample == gPlayerTalkSfx;
+ return nSample == gPlayerTalkSfx ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
}
bool8
@@ -1298,7 +1298,7 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
}
#endif
-bool8
+uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
@@ -1313,10 +1313,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
uint8 slot = nCurrentPedSlot - i - 1;
#endif
if ( nComment == nPedSlotSfx[slot] )
- return TRUE;
+ return LOADING_STATUS_LOADED;
}
- return FALSE;
+ return LOADING_STATUS_NOT_LOADED;
}
@@ -1543,11 +1543,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
#endif
else
{
- if ( !IsPedCommentLoaded(nSfx) )
+ int32 i;
+ for ( i = 0; i < _TODOCONST(3); i++ )
+ {
+ int32 slot = nCurrentPedSlot - i - 1;
+#ifdef FIX_BUGS
+ if (slot < 0)
+ slot += ARRAY_SIZE(nPedSlotSfx);
+#endif
+ if ( nSfx == nPedSlotSfx[slot] )
+ {
+ addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
+ break;
+ }
+ }
+
+ if (i == _TODOCONST(3))
return FALSE;
-
- int32 slot = _GetPedCommentSlot(nSfx);
- addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
}
if ( GetChannelUsedFlag(nChannel) )