feat(sound): add SESound::Heartbeat

This commit is contained in:
fallenoak 2025-11-25 00:09:50 -06:00
parent 029735a1de
commit 7ef63156f9
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 36 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include "sound/SESound.hpp"
#include "event/Event.hpp"
#include "console/CVar.hpp"
#include "util/SFile.hpp"
#include <storm/Memory.hpp>
@ -8,6 +9,7 @@
#define LOG_WRITE(result, ...) \
SESound::Log_Write(__LINE__, __FILE__, result, __VA_ARGS__);
SCritSect SESound::s_CritSect3;
int32_t SESound::s_Initialized;
SCritSect SESound::s_InternalCritSect;
TSHashTable<SOUND_INTERNAL_LOOKUP, HASHKEY_NONE> SESound::s_InternalLookupTable;
@ -107,6 +109,30 @@ FMOD::SoundGroup* SESound::CreateSoundGroup(const char* name, int32_t maxAudible
return group;
}
int32_t SESound::Heartbeat(const void* data, void* param) {
if (!SESound::s_Initialized) {
SESound::s_pGameSystem->update();
return 1;
}
SESound::s_CritSect3.Enter();
// TODO
SESound::ProcessLoadedDiskSounds();
// TODO
SESound::s_pGameSystem->update();
// TODO
SESound::s_CritSect3.Leave();
return 1;
}
void SESound::Init(int32_t maxChannels, int32_t* a2, int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void* a8, int32_t a9) {
SESound::s_Initialized = 0;
@ -160,7 +186,9 @@ void SESound::Init(int32_t maxChannels, int32_t* a2, int32_t enableReverb, int32
SESound::s_pGameSystem->setOutput(FMOD_OUTPUTTYPE_AUTODETECT);
// TODO
// Register heartbeat
EventRegister(EVENT_ID_POLL, &SESound::Heartbeat);
// Get FMOD version
@ -370,6 +398,10 @@ void SESound::Log_Write(int32_t line, const char* file, FMOD_RESULT result, cons
// TODO
}
void SESound::ProcessLoadedDiskSounds() {
// TODO
}
void SESound::CompleteLoad() {
if (!this->m_internal) {
return;

View File

@ -14,6 +14,7 @@ struct SOUND_INTERNAL_LOOKUP : TSHashObject<SOUND_INTERNAL_LOOKUP, HASHKEY_NONE>
class SESound {
public:
// Public static variables
static SCritSect s_CritSect3;
static int32_t s_Initialized;
static SCritSect s_InternalCritSect;
static TSHashTable<SOUND_INTERNAL_LOOKUP, HASHKEY_NONE> s_InternalLookupTable;
@ -24,6 +25,7 @@ class SESound {
// Public static functions
static FMOD::SoundGroup* CreateSoundGroup(const char* name, int32_t maxAudible);
static int32_t Heartbeat(const void* data, void* param);
static void Init(int32_t maxChannels, int32_t (*a2), int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void (*a8), int32_t a9);
static int32_t IsInitialized();
static void Log_Write(int32_t line, const char* file, FMOD_RESULT result, const char* fmt, ...);
@ -35,6 +37,7 @@ class SESound {
private:
// Private static functions
static int32_t LoadDiskSound(FMOD::System* fmodSystem, const char* filename, FMOD_MODE fmodMode, SESound* sound, FMOD::SoundGroup* fmodSoundGroup1, FMOD::SoundGroup* fmodSoundGroup2, bool a7, int32_t a8, uint32_t a9, int32_t a10, uint32_t decodeBufferSize, int32_t a12, float a13, float a14, float a15, float* a16);
static void ProcessLoadedDiskSounds();
// Private member variables
SESoundInternal* m_internal = nullptr;