mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 16:22:45 +03:00
feat(sound): partially implement SEDiskSound::CompleteNonBlockingLoad
This commit is contained in:
parent
163f02a332
commit
74aed41bc5
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user