LAB: Bugfix for freeMusic()

This commit is contained in:
Filippos Karapetis 2015-02-26 01:14:47 +02:00 committed by Eugene Sandulenko
parent 219811feaa
commit 4cf271054a

View file

@ -117,7 +117,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO); Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
uint loops = (_loopSoundEffect) ? 0 : 1; uint loops = (_loopSoundEffect) ? 0 : 1;
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops, DisposeAfterUse::YES); Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream); g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
} }
@ -143,7 +143,6 @@ void Music::fillbuffer(byte *musicBuffer) {
} }
} }
/*****************************************************************************/ /*****************************************************************************/
/* Fills up the buffers that have already been played if necessary; if doit */ /* Fills up the buffers that have already been played if necessary; if doit */
/* is set to TRUE then it will fill up all empty buffers. Otherwise, it */ /* is set to TRUE then it will fill up all empty buffers. Otherwise, it */
@ -153,7 +152,6 @@ void Music::fillUpMusic(bool doit) {
updateMusic(); updateMusic();
} }
/*****************************************************************************/ /*****************************************************************************/
/* Starts up the music initially. */ /* Starts up the music initially. */
/*****************************************************************************/ /*****************************************************************************/
@ -172,7 +170,6 @@ void Music::startMusic(bool startatbegin) {
updateMusic(); updateMusic();
} }
/*****************************************************************************/ /*****************************************************************************/
/* Initializes the music buffers. */ /* Initializes the music buffers. */
/*****************************************************************************/ /*****************************************************************************/
@ -198,27 +195,21 @@ bool Music::initMusic() {
return false; return false;
} }
/*****************************************************************************/ /*****************************************************************************/
/* Frees up the music buffers and closes the file. */ /* Frees up the music buffers and closes the file. */
/*****************************************************************************/ /*****************************************************************************/
void Music::freeMusic() { void Music::freeMusic() {
_musicOn = false; _musicOn = false;
if (_file->isOpen())
_file->close();
_file = 0;
g_lab->_mixer->stopHandle(_musicHandle); g_lab->_mixer->stopHandle(_musicHandle);
_queuingAudioStream = NULL;
g_lab->_mixer->stopHandle(_sfxHandle); g_lab->_mixer->stopHandle(_sfxHandle);
delete _queuingAudioStream; delete _file;
_queuingAudioStream = NULL; _file = NULL;
} }
/*****************************************************************************/ /*****************************************************************************/
/* Pauses the background music. */ /* Pauses the background music. */
/*****************************************************************************/ /*****************************************************************************/
@ -234,8 +225,6 @@ void Music::pauseBackMusic() {
} }
} }
/*****************************************************************************/ /*****************************************************************************/
/* Resumes the paused background music. */ /* Resumes the paused background music. */
/*****************************************************************************/ /*****************************************************************************/
@ -251,7 +240,6 @@ void Music::resumeBackMusic() {
} }
} }
/*****************************************************************************/ /*****************************************************************************/
/* Checks to see if need to fill buffers fill of music. */ /* Checks to see if need to fill buffers fill of music. */
/*****************************************************************************/ /*****************************************************************************/
@ -264,8 +252,6 @@ void Music::checkMusic() {
fillUpMusic(false); fillUpMusic(false);
} }
/*****************************************************************************/ /*****************************************************************************/
/* Checks to see if need to fill buffers fill of music. */ /* Checks to see if need to fill buffers fill of music. */
/*****************************************************************************/ /*****************************************************************************/
@ -273,10 +259,6 @@ void Music::newCheckMusic() {
checkMusic(); checkMusic();
} }
/*****************************************************************************/ /*****************************************************************************/
/* Turns the music on and off. */ /* Turns the music on and off. */
/*****************************************************************************/ /*****************************************************************************/
@ -319,8 +301,6 @@ void Music::changeMusic(const char *newmusic) {
} }
} }
/*****************************************************************************/ /*****************************************************************************/
/* Changes the background music to the original piece playing. */ /* Changes the background music to the original piece playing. */
/*****************************************************************************/ /*****************************************************************************/
@ -351,7 +331,6 @@ void Music::resetMusic() {
_tFile = 0; _tFile = 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/* Checks whether or note enough memory in music buffer before loading any */ /* Checks whether or note enough memory in music buffer before loading any */
/* files. Fills it if not. Does not take into account the current buffer */ /* files. Fills it if not. Does not take into account the current buffer */