huge CVS merge, see ChangeLog for details.
[supertux.git] / src / sound.c
index 4cca05b..a7b4241 100644 (file)
   April 22, 2000 - December 28, 2003
 */
 
-/* why do we need this ?
-#ifdef LINUX
-#include <pwd.h>
-#include <sys/types.h>
-#include <ctype.h>
-#endif
-*/
-
 #include "defines.h"
 #include "globals.h"
 #include "sound.h"
 #include "setup.h"
 
+/*global variable*/
+int use_sound;           /* handle sound on/off menu and command-line option */
+int use_music;           /* handle music on/off menu and command-line option */
+int audio_device;        /* != 0: available and initialized */
+int current_music;
+
 char * soundfilenames[NUM_SOUNDS] = {
                                       DATA_PREFIX "/sounds/jump.wav",
                                       DATA_PREFIX "/sounds/bigjump.wav",
@@ -49,6 +47,9 @@ char * soundfilenames[NUM_SOUNDS] = {
 
 #include <SDL_mixer.h>
 
+Mix_Chunk * sounds[NUM_SOUNDS];
+Mix_Music * level_song, * level_song_fast, * herring_song;
+
 /* --- OPEN THE AUDIO DEVICE --- */
 
 int open_audio (int frequency, Uint16 format, int channels, int chunksize)
@@ -207,8 +208,30 @@ void free_music(Mix_Music *music)
     }
 }
 
+void play_current_music(void)
+{
+          switch (current_music)
+            {
+            case LEVEL_MUSIC:
+              play_music(level_song, 1);
+              break;
+            case HERRING_MUSIC:
+              play_music(herring_song, 1);
+              break;
+            case HURRYUP_MUSIC: // keep the compiler happy
+              play_music(level_song_fast, 1);
+              break;
+            case NO_MUSIC:      // keep the compiler happy for the moment :-)
+            {}
+              /*default:*/
+            }
+}
+
 #else
 
+void* sounds[NUM_SOUNDS];
+void* level_song, *herring_song;
+
 int open_audio (int frequency, int format, int channels, int chunksize)
 {
   return -1;
@@ -258,4 +281,7 @@ void free_music(void *music)
 void free_chunk(void *chunk)
 {}
 
+void play_current_music(void)
+{}
+
 #endif