mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(sound): add SESound::StopOrFadeOut
This commit is contained in:
parent
775c1cbce8
commit
916c23acb2
@ -337,21 +337,7 @@ int32_t SESound::LoadDiskSound(FMOD::System* fmodSystem, const char* filename, F
|
||||
return 0;
|
||||
}
|
||||
|
||||
FMOD_RESULT result;
|
||||
|
||||
if (sound->m_internal) {
|
||||
// TODO sound->m_internal->byte6D = 1;
|
||||
|
||||
if (sound->m_internal->m_fmodChannel) {
|
||||
sound->m_internal->m_fmodChannel->stop();
|
||||
sound->m_internal->m_fmodChannel = nullptr;
|
||||
}
|
||||
|
||||
if (sound->m_internal) {
|
||||
sound->m_internal->m_sound = nullptr;
|
||||
sound->m_internal = nullptr;
|
||||
}
|
||||
}
|
||||
sound->StopOrFadeOut(1, -1.0f);
|
||||
|
||||
auto internal = STORM_NEW(SEDiskSound);
|
||||
|
||||
@ -460,6 +446,8 @@ int32_t SESound::LoadDiskSound(FMOD::System* fmodSystem, const char* filename, F
|
||||
|
||||
// Create FMOD stream or sound
|
||||
|
||||
FMOD_RESULT result;
|
||||
|
||||
if (fileSize > maxCacheSize || !useCache) {
|
||||
useCache = false;
|
||||
|
||||
@ -635,3 +623,28 @@ void SESound::SetVolume(float volume) {
|
||||
this->m_internal->m_fmodChannel->setVolume(this->m_internal->GetVolume());
|
||||
}
|
||||
}
|
||||
|
||||
void SESound::StopOrFadeOut(int32_t stop, float fadeOutTime) {
|
||||
if (!this->m_internal) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fadeOutTime >= 0.0f) {
|
||||
this->m_internal->m_fadeOutTime = fadeOutTime;
|
||||
}
|
||||
|
||||
if (stop || this->m_internal->m_fadeOutTime <= 0.0f) {
|
||||
this->m_internal->m_stopped = 1;
|
||||
|
||||
if (this->m_internal->m_fmodChannel) {
|
||||
this->m_internal->m_fmodChannel->stop();
|
||||
this->m_internal->m_fmodChannel = nullptr;
|
||||
}
|
||||
} else {
|
||||
this->m_internal->m_fadeIn = 0;
|
||||
this->m_internal->m_fadeOut = 1;
|
||||
}
|
||||
|
||||
this->m_internal->m_sound = nullptr;
|
||||
this->m_internal = nullptr;
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ class SESound {
|
||||
void SetFadeOutTime(float fadeOutTime);
|
||||
void SetUserData(SEUserData* userData);
|
||||
void SetVolume(float volume);
|
||||
void StopOrFadeOut(int32_t stop, float fadeOutTime);
|
||||
|
||||
private:
|
||||
// Private static functions
|
||||
|
||||
@ -43,6 +43,7 @@ class SESoundInternal : public TSLinkedNode<SESoundInternal> {
|
||||
// TODO
|
||||
FMOD_MODE m_fmodMode = FMOD_DEFAULT;
|
||||
uint8_t m_playing = 0;
|
||||
uint8_t m_stopped = 0;
|
||||
// TODO
|
||||
int32_t m_nonblockingReady = 0;
|
||||
// TODO
|
||||
|
||||
Loading…
Reference in New Issue
Block a user