- memleak fix and menu fix from MatzeB
[supertux.git] / src / sound.cpp
index 984618a..0098cb0 100644 (file)
 #include "setup.h"
 
 /*global variable*/
-bool use_sound;           /* handle sound on/off menu and command-line option */
-bool use_music;           /* handle music on/off menu and command-line option */
-bool audio_device;        /* != 0: available and initialized */
-int current_music;
+bool use_sound = true;    /* handle sound on/off menu and command-line option */
+bool use_music = true;    /* handle music on/off menu and command-line option */
+bool audio_device = true; /* != 0: available and initialized */
 
 char * soundfilenames[NUM_SOUNDS] = {
                                        "/sounds/jump.wav",
@@ -47,15 +46,14 @@ char * soundfilenames[NUM_SOUNDS] = {
                                        "/sounds/shoot.wav",
                                        "/sounds/lifeup.wav",
                                        "/sounds/stomp.wav",
-                                       "/sounds/kick.wav"
+                                       "/sounds/kick.wav",
+                                       "/sounds/explode.wav"
                                     };
 
 
 #include <SDL_mixer.h>
 
 Mix_Chunk * sounds[NUM_SOUNDS];
-Mix_Music * herring_song = 0;
-Mix_Music * current_song = 0;
 
 /* --- OPEN THE AUDIO DEVICE --- */
 
@@ -157,47 +155,3 @@ void free_chunk(Mix_Chunk *chunk)
     }
 }
 
-void halt_music(void)
-{
-  if (!use_music || !audio_device)
-    return;
-
-  Mix_HaltMusic();
-  current_song = 0;
-}
-
-
-void play_music(Mix_Music *music)
-{
-  if (!audio_device)
-    return;
-  if(music == current_song)
-    return;
-
-  if (use_music && Mix_PlayMusic(music, -1) < 0)
-    st_abort("Couldn't play music: ", Mix_GetError());
-
-  current_song = music;
-}
-
-
-void free_music(Mix_Music *music)
-{
-  if(!audio_device)
-    return;
-
-  Mix_FreeMusic( music );
-}
-
-void enable_music(bool enable)
-{
-  if(!audio_device)
-    return;
-  
-  use_music = enable;
-  if(!use_music)
-    Mix_HaltMusic();
-  else
-    Mix_PlayMusic(current_song, -1);
-}
-