Skip to content

Commit 2788abe

Browse files
committed
Added getTotalPlayingSoundCount().
1 parent 8fe26ab commit 2788abe

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

OpenTESArena/src/Audio/AudioManager.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,30 @@ bool AudioManager::anyPlayingSounds(const std::string &filename) const
679679
return false;
680680
}
681681

682+
int AudioManager::getTotalPlayingSoundCount() const
683+
{
684+
int count = 0;
685+
686+
for (const SoundInstance &soundInst : this->soundInstancesPool.values)
687+
{
688+
if (alIsSource(soundInst.source) != AL_TRUE)
689+
{
690+
continue;
691+
}
692+
693+
ALint sourceState;
694+
alGetSourcei(soundInst.source, AL_SOURCE_STATE, &sourceState);
695+
if (sourceState != AL_PLAYING)
696+
{
697+
continue;
698+
}
699+
700+
count++;
701+
}
702+
703+
return count;
704+
}
705+
682706
bool AudioManager::hasNextMusic() const
683707
{
684708
return !mNextSong.empty();

OpenTESArena/src/Audio/AudioManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class AudioManager
124124
// Returns whether the given filename is playing in any sound instance.
125125
bool anyPlayingSounds(const std::string &filename) const;
126126

127+
int getTotalPlayingSoundCount() const;
128+
127129
// Sets the music to the given music definition, with an optional music to play first as a
128130
// lead-in to the actual music. If no music definition is given, the current music is stopped.
129131
void setMusic(const MusicDefinition *musicDef, const MusicDefinition *optMusicDef = nullptr);

0 commit comments

Comments
 (0)