fixed destruction of the sound module
parent
6f3d78dab0
commit
a1be34e1a4
|
@ -66,6 +66,13 @@ int SoundBase::OnInit(int argc, char* argv[]) {
|
|||
|
||||
void SoundBase::OnDestroy() {
|
||||
LogDebug ("Sound Destroy");
|
||||
|
||||
// stop music
|
||||
HaltMusic();
|
||||
|
||||
// stop and clear all samples
|
||||
mSamples.clear();
|
||||
|
||||
Mix_CloseAudio();
|
||||
|
||||
SoundInstance = NULL;
|
||||
|
@ -155,6 +162,17 @@ void SoundBase::PlayMusic (const std::string &music_name) {
|
|||
Mix_PlayMusic(mCurrentMusic, -1);
|
||||
}
|
||||
|
||||
void SoundBase::HaltMusic () {
|
||||
if (!SoundInstance) {
|
||||
LogError("Could not stop music: sound system not initialized!");
|
||||
}
|
||||
|
||||
Mix_HaltMusic();
|
||||
Mix_FreeMusic(mCurrentMusic);
|
||||
mCurrentMusic = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Global Functions
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,7 @@ class SoundBase : public Module {
|
|||
void PlaySoundLoop (const std::string &sound_name, int count);
|
||||
void HaltSoundLoop (const std::string &sound_name);
|
||||
void PlayMusic (const std::string &music_name);
|
||||
void HaltMusic ();
|
||||
|
||||
protected:
|
||||
/** \brief Initializes the system */
|
||||
|
|
Loading…
Reference in New Issue