feat(sound): partially implement SEDiskSound::CompleteNonBlockingLoad

This commit is contained in:
fallenoak 2025-11-24 19:42:05 -06:00
parent 163f02a332
commit 74aed41bc5
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 57 additions and 1 deletions

View File

@ -1,11 +1,64 @@
#include "sound/SESoundInternal.hpp" #include "sound/SESoundInternal.hpp"
#include "sound/SESound.hpp" #include "sound/SESound.hpp"
#define LOG_WRITE(result, ...) \
SESound::Log_Write(__LINE__, __FILE__, result, __VA_ARGS__);
SESoundInternal::SESoundInternal() { SESoundInternal::SESoundInternal() {
// TODO // TODO
this->m_uniqueID = SESound::s_UniqueID++; this->m_uniqueID = SESound::s_UniqueID++;
} }
void SEDiskSound::CompleteNonBlockingLoad() { void SESoundInternal::Play() {
// TODO // 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();
}
}

View File

@ -30,6 +30,7 @@ class SESoundInternal {
int32_t m_type = 0; int32_t m_type = 0;
// TODO // TODO
FMOD_MODE m_fmodMode = FMOD_DEFAULT; FMOD_MODE m_fmodMode = FMOD_DEFAULT;
uint8_t m_playing = 0;
// TODO // TODO
int32_t m_loaded = 0; int32_t m_loaded = 0;
// TODO // TODO
@ -37,6 +38,7 @@ class SESoundInternal {
// Member functions // Member functions
SESoundInternal(); SESoundInternal();
void Play();
}; };
class SEDiskSound : public SESoundInternal { class SEDiskSound : public SESoundInternal {
@ -50,6 +52,7 @@ class SEDiskSound : public SESoundInternal {
SoundCacheNode* m_cacheNode = nullptr; SoundCacheNode* m_cacheNode = nullptr;
// Member functions // Member functions
void Abort(FMOD_RESULT result);
void CompleteNonBlockingLoad(); void CompleteNonBlockingLoad();
}; };