1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Ensure that all channels are halted before free

This commit is contained in:
Mathieu Schroeter 2017-07-30 22:38:51 +02:00
parent 1fe84fcdf7
commit d67010c87a
3 changed files with 11 additions and 4 deletions

View File

@ -2974,7 +2974,7 @@ bool CEvent::ChangePhase (Uint32 phase)
// FIXME: pause is better if the game is not stop but just interrupted
if (m_phase == WM_PHASE_PLAY && m_phase != phase)
m_pSound->StopAllSounds();
m_pSound->StopAllSounds (false);
m_phase = phase; // change de phase
m_index = index;

View File

@ -9,7 +9,7 @@
// Stops all sounds.
bool CSound::StopAllSounds()
bool CSound::StopAllSounds(bool immediat)
{
for (Sint32 i = 0; i < MAXSOUND; i ++)
{
@ -17,7 +17,12 @@ bool CSound::StopAllSounds()
continue;
if (Mix_Playing (i + 1) == SDL_TRUE)
Mix_FadeOutChannel (i + 1, 500);
{
if (immediat)
Mix_HaltChannel (i + 1);
else
Mix_FadeOutChannel (i + 1, 500);
}
}
return true;
@ -114,6 +119,8 @@ void CSound::CacheAll()
Sint32 i;
char name[50];
this->StopAllSounds (true);
for (i = 0 ; i < MAXSOUND ; i++)
{
sprintf (name, "sound%.3d.wav", i);

View File

@ -43,7 +43,7 @@ public:
bool IsStoppedOnDemand();
void AdaptVolumeMusic();
void SetSuspendSkip (Sint32 nb);
bool StopAllSounds();
bool StopAllSounds(bool immediat);
protected:
bool m_bState;