mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(sound): add SESound::GetChannelGroup
This commit is contained in:
parent
cea3d87571
commit
965a85c8ef
@ -186,6 +186,45 @@ FMOD::SoundGroup* SESound::CreateSoundGroup(const char* name, int32_t maxAudible
|
||||
return group;
|
||||
}
|
||||
|
||||
SEChannelGroup* SESound::GetChannelGroup(const char* name, bool create, bool createInMaster) {
|
||||
if (!SESound::s_Initialized) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto nameHash = SStrHashHT(name);
|
||||
|
||||
// No groups or only master group exist
|
||||
|
||||
if (SESound::s_ChannelGroups.Count() <= 1) {
|
||||
if (!create) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto newChannelGroup = SESound::s_ChannelGroups.New();
|
||||
newChannelGroup->m_nameHash = nameHash;
|
||||
newChannelGroup->m_parentChannelGroup = createInMaster ? 0 : -1;
|
||||
newChannelGroup->m_volume = 1.0f;
|
||||
newChannelGroup->m_muteVolume = 1.0f;
|
||||
newChannelGroup->m_dirty = true;
|
||||
|
||||
return newChannelGroup;
|
||||
}
|
||||
|
||||
// Find non-master group matching name hash
|
||||
|
||||
for (int32_t i = 1; i < SESound::s_ChannelGroups.Count(); i++) {
|
||||
auto channelGroup = &SESound::s_ChannelGroups[i];
|
||||
|
||||
if (channelGroup->m_nameHash == nameHash) {
|
||||
return channelGroup;
|
||||
}
|
||||
}
|
||||
|
||||
// No matches
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t SESound::Heartbeat(const void* data, void* param) {
|
||||
if (!SESound::s_Initialized) {
|
||||
SESound::s_pGameSystem->update();
|
||||
|
||||
@ -31,6 +31,7 @@ class SESound {
|
||||
|
||||
// Public static functions
|
||||
static FMOD::SoundGroup* CreateSoundGroup(const char* name, int32_t maxAudible);
|
||||
static SEChannelGroup* GetChannelGroup(const char* name, bool create, bool createInMaster);
|
||||
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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user