mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-25 12:13:44 +00:00
Audio: separate buffers for mission audio
This commit is contained in:
parent
29383a6a11
commit
232a45c9ac
4 changed files with 110 additions and 47 deletions
|
@ -8307,7 +8307,6 @@ cPedComments::Process()
|
|||
goto PedCommentAlreadyAdded;
|
||||
}
|
||||
}
|
||||
#if defined(GTA_PS2) || defined(FIX_BUGS)
|
||||
bool8 IsLoadedResult;
|
||||
sampleIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex;
|
||||
if (sampleIndex >= PLAYER_COMMENTS_START && sampleIndex <= PLAYER_COMMENTS_END) {
|
||||
|
@ -8318,18 +8317,13 @@ cPedComments::Process()
|
|||
bIsPlayerComment = FALSE;
|
||||
}
|
||||
switch(IsLoadedResult) { // yes, this was a switch
|
||||
#else
|
||||
switch(SampleManager.IsPedCommentLoaded(sampleIndex)) { // yes, this was a switch
|
||||
#endif
|
||||
case FALSE:
|
||||
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
||||
if(!m_bDelay)
|
||||
#endif
|
||||
#if defined(GTA_PS2) || defined(FIX_BUGS)
|
||||
if (bIsPlayerComment)
|
||||
SampleManager.LoadMissionAudio(MISSION_AUDIO_PLAYER_COMMENT, sampleIndex);
|
||||
else
|
||||
#endif
|
||||
SampleManager.LoadPedComment(sampleIndex);
|
||||
break;
|
||||
case TRUE:
|
||||
|
@ -11863,8 +11857,8 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
if (m_nMissionAudioSampleIndex[slot] != NO_SAMPLE) {
|
||||
switch (m_nMissionAudioLoadingStatus[slot]) {
|
||||
case LOADING_STATUS_NOT_LOADED:
|
||||
// TODO: LoadMissionAudio
|
||||
SampleManager.LoadPedComment(m_nMissionAudioSampleIndex[slot]);
|
||||
if (!SampleManager.IsMissionAudioLoaded(slot, m_nMissionAudioSampleIndex[slot]))
|
||||
SampleManager.LoadMissionAudio(slot, m_nMissionAudioSampleIndex[slot]);
|
||||
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot]));
|
||||
m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED;
|
||||
nFramesUntilFailedLoad[slot] = 0;
|
||||
|
|
|
@ -112,7 +112,8 @@ enum
|
|||
#endif
|
||||
};
|
||||
#define MAX_PEDSFX 7
|
||||
#define PED_BLOCKSIZE 160000
|
||||
#define PED_BLOCKSIZE 79000
|
||||
#define MISSION_AUDIO_BLOCKSIZE 160000
|
||||
|
||||
#define MAXPROVIDERS 64
|
||||
|
||||
|
@ -207,10 +208,8 @@ public:
|
|||
void UnloadSampleBank (uint8 nBank);
|
||||
bool8 IsSampleBankLoaded(uint8 nBank);
|
||||
|
||||
#if defined (GTA_PS2) || defined (FIX_BUGS)
|
||||
bool8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
|
||||
bool8 LoadMissionAudio (uint8 nSlot, uint32 nSample);
|
||||
#endif
|
||||
|
||||
bool8 IsPedCommentLoaded(uint32 nComment);
|
||||
bool8 LoadPedComment (uint32 nComment);
|
||||
|
|
|
@ -39,10 +39,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
|
|||
int32 nPedSlotSfxAddr[MAX_PEDSFX];
|
||||
uint8 nCurrentPedSlot;
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
uint32 nMissionSlotSfx[MISSION_AUDIO_SLOTS] = { UINT32_MAX, UINT32_MAX };
|
||||
uintptr nMissionSlotSfxStartAddress;
|
||||
|
||||
uint32 gPlayerTalkSfx = UINT32_MAX;
|
||||
void *gPlayerTalkData = 0;
|
||||
#endif
|
||||
|
||||
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
|
||||
|
||||
|
@ -1323,7 +1324,13 @@ cSampleManager::Initialise(void)
|
|||
|
||||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX);
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
nMissionSlotSfxStartAddress = (uintptr)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX);
|
||||
if ( !nMissionSlotSfxStartAddress )
|
||||
{
|
||||
Terminate();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Find biggest player comment
|
||||
uint32 nMaxPedSize = 0;
|
||||
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
|
||||
|
@ -1335,7 +1342,6 @@ cSampleManager::Initialise(void)
|
|||
Terminate();
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
LoadSampleBank(SFX_BANK_0);
|
||||
|
||||
|
@ -1491,13 +1497,20 @@ cSampleManager::Terminate(void)
|
|||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
if ( nMissionSlotSfxStartAddress != 0 )
|
||||
{
|
||||
AIL_mem_free_lock((void *)nMissionSlotSfxStartAddress);
|
||||
nMissionSlotSfxStartAddress = 0;
|
||||
|
||||
for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ )
|
||||
nMissionSlotSfx[i] = UINT32_MAX;
|
||||
}
|
||||
|
||||
if ( gPlayerTalkData != 0)
|
||||
{
|
||||
AIL_mem_free_lock(gPlayerTalkData);
|
||||
gPlayerTalkData = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( DIG )
|
||||
{
|
||||
|
@ -1663,32 +1676,50 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
|
|||
return bSampleBankLoaded[nBank];
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
bool8
|
||||
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
|
||||
|
||||
return nSample == gPlayerTalkSfx;
|
||||
switch (nSlot)
|
||||
{
|
||||
case MISSION_AUDIO_SLOT_1:
|
||||
case MISSION_AUDIO_SLOT_2:
|
||||
return nMissionSlotSfx[nSlot] == nSample;
|
||||
case MISSION_AUDIO_PLAYER_COMMENT:
|
||||
return nSample == gPlayerTalkSfx;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
|
||||
ASSERT(nSample < TOTAL_AUDIO_SAMPLES);
|
||||
|
||||
if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
switch (nSlot)
|
||||
{
|
||||
case MISSION_AUDIO_SLOT_1:
|
||||
case MISSION_AUDIO_SLOT_2:
|
||||
if (fread((void*)(nMissionSlotSfxStartAddress + nSlot*MISSION_AUDIO_BLOCKSIZE), 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
nMissionSlotSfx[nSlot] = nSample;
|
||||
break;
|
||||
case MISSION_AUDIO_PLAYER_COMMENT:
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool8
|
||||
cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||
|
@ -1917,7 +1948,6 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
|
||||
}
|
||||
#ifdef FIX_BUGS
|
||||
else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END )
|
||||
{
|
||||
if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) )
|
||||
|
@ -1925,9 +1955,15 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = (uintptr)gPlayerTalkData;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
{
|
||||
for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ ) {
|
||||
if ( IsMissionAudioLoaded(i, nSfx) ) {
|
||||
addr = nMissionSlotSfxStartAddress + i * MISSION_AUDIO_BLOCKSIZE;
|
||||
goto MissionAudioFound;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !IsPedCommentLoaded(nSfx) )
|
||||
return FALSE;
|
||||
|
||||
|
@ -1936,6 +1972,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
addr = nPedSlotSfxAddr[slot];
|
||||
}
|
||||
|
||||
MissionAudioFound:
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
if ( b2d )
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ OggOpusFile *fpSampleDataHandle;
|
|||
#else
|
||||
FILE *fpSampleDataHandle;
|
||||
#endif
|
||||
bool8 bSampleBankLoaded [MAX_SFX_BANKS];
|
||||
bool8 bSampleBankLoaded [MAX_SFX_BANKS];
|
||||
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
|
||||
int32 nSampleBankSize [MAX_SFX_BANKS];
|
||||
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
|
||||
|
@ -102,10 +102,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
|
|||
int32 nPedSlotSfxAddr[MAX_PEDSFX];
|
||||
uint8 nCurrentPedSlot;
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
uint32 nMissionSlotSfx[MISSION_AUDIO_SLOTS] = { UINT32_MAX, UINT32_MAX };
|
||||
uintptr nMissionSlotSfxStartAddress;
|
||||
|
||||
uint32 gPlayerTalkSfx = UINT32_MAX;
|
||||
void *gPlayerTalkData = 0;
|
||||
#endif
|
||||
|
||||
CChannel aChannel[NUM_CHANNELS];
|
||||
uint8 nChannelVolume[NUM_CHANNELS];
|
||||
|
@ -1053,7 +1054,9 @@ cSampleManager::Initialise(void)
|
|||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
|
||||
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
nMissionSlotSfxStartAddress = (uintptr)malloc(MISSION_AUDIO_BLOCKSIZE*MISSION_AUDIO_SLOTS);
|
||||
ASSERT(nMissionSlotSfxStartAddress != 0);
|
||||
|
||||
// Find biggest player comment
|
||||
uint32 nMaxPedSize = 0;
|
||||
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
|
||||
|
@ -1061,7 +1064,6 @@ cSampleManager::Initialise(void)
|
|||
|
||||
gPlayerTalkData = malloc(nMaxPedSize);
|
||||
ASSERT(gPlayerTalkData != 0);
|
||||
#endif
|
||||
|
||||
LoadSampleBank(SFX_BANK_0);
|
||||
}
|
||||
|
@ -1223,13 +1225,20 @@ cSampleManager::Terminate(void)
|
|||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
if ( nMissionSlotSfxStartAddress != 0 )
|
||||
{
|
||||
free((void*)nMissionSlotSfxStartAddress);
|
||||
nMissionSlotSfxStartAddress = 0;
|
||||
|
||||
for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ )
|
||||
nMissionSlotSfx[i] = UINT32_MAX;
|
||||
}
|
||||
|
||||
if ( gPlayerTalkData != 0 )
|
||||
{
|
||||
free(gPlayerTalkData);
|
||||
gPlayerTalkData = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
_bSampmanInitialised = FALSE;
|
||||
}
|
||||
|
@ -1355,32 +1364,50 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
|
|||
return bSampleBankLoaded[nBank];
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
bool8
|
||||
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
|
||||
return nSample == gPlayerTalkSfx;
|
||||
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
|
||||
|
||||
switch (nSlot)
|
||||
{
|
||||
case MISSION_AUDIO_SLOT_1:
|
||||
case MISSION_AUDIO_SLOT_2:
|
||||
return nMissionSlotSfx[nSlot] == nSample;
|
||||
case MISSION_AUDIO_PLAYER_COMMENT:
|
||||
return nSample == gPlayerTalkSfx;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
|
||||
ASSERT(nSample < TOTAL_AUDIO_SAMPLES);
|
||||
|
||||
if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
switch (nSlot)
|
||||
{
|
||||
case MISSION_AUDIO_SLOT_1:
|
||||
case MISSION_AUDIO_SLOT_2:
|
||||
if (fread((void*)(nMissionSlotSfxStartAddress + nSlot*MISSION_AUDIO_BLOCKSIZE), 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
nMissionSlotSfx[nSlot] = nSample;
|
||||
break;
|
||||
case MISSION_AUDIO_PLAYER_COMMENT:
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool8
|
||||
cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||
|
@ -1616,7 +1643,6 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
|
||||
}
|
||||
#ifdef FIX_BUGS
|
||||
else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END )
|
||||
{
|
||||
if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) )
|
||||
|
@ -1624,16 +1650,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = (uintptr)gPlayerTalkData;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ ) {
|
||||
if ( IsMissionAudioLoaded(i, nSfx) ) {
|
||||
addr = nMissionSlotSfxStartAddress + i * MISSION_AUDIO_BLOCKSIZE;
|
||||
goto MissionAudioFound;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !IsPedCommentLoaded(nSfx) )
|
||||
return FALSE;
|
||||
|
||||
int32 slot = _GetPedCommentSlot(nSfx);
|
||||
addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
|
||||
}
|
||||
|
||||
|
||||
MissionAudioFound:
|
||||
if ( GetChannelUsedFlag(nChannel) )
|
||||
{
|
||||
TRACE("Stopping channel %d - really!!!", nChannel);
|
||||
|
|
Loading…
Reference in a new issue