hedgewars/uSound.pas
changeset 3697 d5b30d6373fc
parent 3667 9359a70df013
child 3825 fd6c20cd90e3
equal deleted inserted replaced
3695:c11abf387a7d 3697:d5b30d6373fc
   121 
   121 
   122 {$IFDEF SDL_MIXER_NEWER}
   122 {$IFDEF SDL_MIXER_NEWER}
   123     // make sure all instances of sdl_mixer are unloaded before continuing
   123     // make sure all instances of sdl_mixer are unloaded before continuing
   124     while Mix_Init(0) <> 0 do
   124     while Mix_Init(0) <> 0 do
   125         Mix_Quit();
   125         Mix_Quit();
   126 {$ENDIF}    
   126 {$ENDIF}
   127 
   127 
   128     Mix_CloseAudio();
   128     Mix_CloseAudio();
   129 end;
   129 end;
   130 
   130 
   131 procedure SoundLoad;
   131 procedure SoundLoad;
   134     s:shortstring;
   134     s:shortstring;
   135 begin
   135 begin
   136     if not isSoundEnabled then exit;
   136     if not isSoundEnabled then exit;
   137 
   137 
   138     defVoicepack:= AskForVoicepack('Default');
   138     defVoicepack:= AskForVoicepack('Default');
   139     
   139 
   140     for t:= 0 to cMaxTeams do
   140     for t:= 0 to cMaxTeams do
   141         if voicepacks[t].name <> '' then
   141         if voicepacks[t].name <> '' then
   142             for i:= Low(TSound) to High(TSound) do
   142             for i:= Low(TSound) to High(TSound) do
   143                 voicepacks[t].chunks[i]:= nil;
   143                 voicepacks[t].chunks[i]:= nil;
   144     
   144 
   145     for i:= Low(TSound) to High(TSound) do
   145     for i:= Low(TSound) to High(TSound) do
   146     begin
   146     begin
   147         defVoicepack^.chunks[i]:= nil;
   147         defVoicepack^.chunks[i]:= nil;
   148         // preload all the big sound files (>32k) that would otherwise lockup the game
   148         // preload all the big sound files (>32k) that would otherwise lockup the game
   149         if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) 
   149         if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo])
   150             and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
   150             and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
   151         begin
   151         begin
   152             s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
   152             s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
   153             WriteToConsole(msgLoading + s + ' ');
   153             WriteToConsole(msgLoading + s + ' ');
   154             defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
   154             defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);