Game Development Reference
In-Depth Information
AudioBufferList m_AllSamples; // List of all currently allocated buffers
bool m_AllPaused;
// Has the sound system been paused?
bool m_Initialized;
// Has the sound system been initialized?
};
We ' ll use STL to organize the active sounds in a linked list called m_AllSamples .
This is probably good for almost any game because you
ll most likely have only a
handful of sounds active at one time. Linked lists are great containers for a small
number of objects. Since the sounds are all stored in the linked list, and each sound
object implements the IAudioBuffer interface, you can define routines that per-
form an action on every sound in the system.
'
void Audio::VShutdown()
{
AudioBufferList::iterator i=m_AllSamples.begin();
while (i!=m_AllSamples.end())
{
IAudioBuffer *audioBuffer = (*i);
audioBuffer->VStop();
m_AllSamples.pop_front();
}
}
//Stop all active sounds, including music
void Audio::VPauseAllSounds()
{
AudioBufferList::iterator i;
AudioBufferList::iterator end;
for(i=m_AllSamples.begin(), end=m_AllSamples.end(); i!=end; ++i)
{
IAudioBuffer *audioBuffer = (*i);
audioBuffer->VPause();
}
m_AllPaused=true;
}
void Audio::VResumeAllSounds()
{
AudioBufferList::iterator i;
AudioBufferList::iterator end;
for(i=m_AllSamples.begin(), end=m_AllSamples.end(); i!=end; ++i)
{
IAudioBuffer *audioBuffer = (*i);
audioBuffer->VResume();
Search WWH ::




Custom Search