diff --git a/src/sound/SESound.cpp b/src/sound/SESound.cpp index 78577ec..b02d68a 100644 --- a/src/sound/SESound.cpp +++ b/src/sound/SESound.cpp @@ -1,4 +1,5 @@ #include "sound/SESound.hpp" +#include "event/Event.hpp" #include "console/CVar.hpp" #include "util/SFile.hpp" #include @@ -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 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; diff --git a/src/sound/SESound.hpp b/src/sound/SESound.hpp index b47fb23..feb6438 100644 --- a/src/sound/SESound.hpp +++ b/src/sound/SESound.hpp @@ -14,6 +14,7 @@ struct SOUND_INTERNAL_LOOKUP : TSHashObject class SESound { public: // Public static variables + static SCritSect s_CritSect3; static int32_t s_Initialized; static SCritSect s_InternalCritSect; static TSHashTable 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;