# HG changeset patch # User smxx # Date 1269971042 0 # Node ID f75d546414c4b1ca3c60ac0a1d28e0634b4ed6e3 # Parent 5c350b6c38f40c1acf337c1a8d59a3df281e9d76 Engine: * Ensure support libs are unloaded properly before trying to call Mix_CloseAudio() - fixes SegFault when running newer versions of SDL_mixer diff -r 5c350b6c38f4 -r f75d546414c4 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Tue Mar 30 17:17:15 2010 +0000 +++ b/hedgewars/uSound.pas Tue Mar 30 17:44:02 2010 +0000 @@ -83,6 +83,12 @@ if isSoundEnabled then isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; +{$IFDEF SDL_MIXER_NEWER} + WriteToConsole('Init SDL_mixer... '); + SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); + WriteLnToConsole(msgOK); +{$ENDIF} + if isSoundEnabled then WriteLnToConsole(msgOK) else @@ -108,7 +114,15 @@ if voicepacks[t].chunks[i] <> nil then Mix_FreeChunk(voicepacks[t].chunks[i]); -Mix_FreeMusic(Mus); +if Mus <> nil then + Mix_FreeMusic(Mus); + +{$IFDEF SDL_MIXER_NEWER} +// make sure all instances of sdl_mixer are unloaded before continuing +while Mix_Init(0) <> 0 do + Mix_Quit(); +{$ENDIF} + Mix_CloseAudio(); end; @@ -119,12 +133,6 @@ begin if not isSoundEnabled then exit; -{$IFDEF SDL_MIXER_NEWER} - WriteToConsole('Init SDL_mixer... '); - SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); - WriteLnToConsole(msgOK); -{$ENDIF} - defVoicepack:= AskForVoicepack('Default'); for i:= Low(TSound) to High(TSound) do @@ -150,9 +158,6 @@ else WriteLnToConsole(msgOK) end; -{$IFDEF SDL_MIXER_NEWER} - Mix_Quit(); -{$ENDIF} end; procedure PlaySound(snd: TSound);