From 74aed41bc539483860bf6a6ae4bd363cd1d9a10c Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 24 Nov 2025 19:42:05 -0600 Subject: [PATCH] feat(sound): partially implement SEDiskSound::CompleteNonBlockingLoad --- src/sound/SESoundInternal.cpp | 55 ++++++++++++++++++++++++++++++++++- src/sound/SESoundInternal.hpp | 3 ++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/sound/SESoundInternal.cpp b/src/sound/SESoundInternal.cpp index 107ffb5..85a70aa 100644 --- a/src/sound/SESoundInternal.cpp +++ b/src/sound/SESoundInternal.cpp @@ -1,11 +1,64 @@ #include "sound/SESoundInternal.hpp" #include "sound/SESound.hpp" +#define LOG_WRITE(result, ...) \ + SESound::Log_Write(__LINE__, __FILE__, result, __VA_ARGS__); + SESoundInternal::SESoundInternal() { // TODO this->m_uniqueID = SESound::s_UniqueID++; } -void SEDiskSound::CompleteNonBlockingLoad() { +void SESoundInternal::Play() { // TODO } + +void SEDiskSound::Abort(FMOD_RESULT result) { + // TODO +} + +void SEDiskSound::CompleteNonBlockingLoad() { + FMOD_RESULT result; + + // Validate sound + + if (!this->m_fmodSound) { + LOG_WRITE(FMOD_ERR_INTERNAL, "##### ERROR! INVALID m_fmodSound"); + this->Abort(FMOD_OK); + + return; + } + + // Prepare sound for playback (mark as paused to permit additional setup) + + result = this->m_fmodSystem->playSound(this->m_fmodSound, nullptr, true, &this->m_fmodChannel); + + if (result != FMOD_OK) { + if (result != FMOD_ERR_MAXAUDIBLE) { + LOG_WRITE(result, "CNBL: playSound Failed"); + } + + this->Abort(result); + + return; + } + + // Store internal sound ID in FMOD user data + + result = this->m_fmodChannel->setUserData(&this->m_uniqueID); + + if (result != FMOD_OK) { + LOG_WRITE(result, "CNBL: setUserData Failed"); + this->Abort(result); + + return; + } + + // TODO + + // Play sound if appropriate + + if (this->m_playing) { + this->Play(); + } +} diff --git a/src/sound/SESoundInternal.hpp b/src/sound/SESoundInternal.hpp index 780a745..3ba030f 100644 --- a/src/sound/SESoundInternal.hpp +++ b/src/sound/SESoundInternal.hpp @@ -30,6 +30,7 @@ class SESoundInternal { int32_t m_type = 0; // TODO FMOD_MODE m_fmodMode = FMOD_DEFAULT; + uint8_t m_playing = 0; // TODO int32_t m_loaded = 0; // TODO @@ -37,6 +38,7 @@ class SESoundInternal { // Member functions SESoundInternal(); + void Play(); }; class SEDiskSound : public SESoundInternal { @@ -50,6 +52,7 @@ class SEDiskSound : public SESoundInternal { SoundCacheNode* m_cacheNode = nullptr; // Member functions + void Abort(FMOD_RESULT result); void CompleteNonBlockingLoad(); };