fixed compiler warnings (after adding "-Wstrict-prototypes")
[rocksndiamonds.git] / src / libgame / sound.c
index 15354b68575dbc6b95b97563b996905ed17f24cb..6f9dcaf1d88e21b6e10d5351e8b5ab4921e7a1e3 100644 (file)
@@ -59,9 +59,9 @@
 #define SOUND_VOLUME_LOOPS(v)  SOUND_VOLUME_FROM_PERCENT(v, setup.volume_loops)
 #define SOUND_VOLUME_MUSIC(v)  SOUND_VOLUME_FROM_PERCENT(v, setup.volume_music)
 
-#define SETUP_SOUND_VOLUME(v,s)                ((s) == SND_CTRL_PLAY_MUSIC ?   \
+#define SETUP_SOUND_VOLUME(v,s)                ((s) & SND_CTRL_MUSIC ?         \
                                         SOUND_VOLUME_MUSIC(v) :        \
-                                        (s) == SND_CTRL_PLAY_LOOP ?    \
+                                        (s) & SND_CTRL_LOOP ?          \
                                         SOUND_VOLUME_LOOPS(v) :        \
                                         SOUND_VOLUME_SIMPLE(v))
 
@@ -126,11 +126,11 @@ static struct SoundControl mixer[NUM_MIXER_CHANNELS];
 static int mixer_active_channels = 0;
 static boolean expire_loop_sounds = FALSE;
 
-static void ReloadCustomSounds();
-static void ReloadCustomMusic();
+static void ReloadCustomSounds(void);
+static void ReloadCustomMusic(void);
 static void FreeSound(void *);
 static void FreeMusic(void *);
-static void FreeAllMusic_NoConf();
+static void FreeAllMusic_NoConf(void);
 
 static SoundInfo *getSoundInfoEntryFromSoundID(int);
 static MusicInfo *getMusicInfoEntryFromMusicID(int);
@@ -140,7 +140,7 @@ static MusicInfo *getMusicInfoEntryFromMusicID(int);
 /* mixer functions                                                           */
 /* ------------------------------------------------------------------------- */
 
-void Mixer_InitChannels()
+void Mixer_InitChannels(void)
 {
   int i;
 
@@ -215,16 +215,18 @@ static void Mixer_PlayChannel(int channel)
   mixer_active_channels++;
 }
 
-static void Mixer_PlayMusicChannel()
+static void Mixer_PlayMusicChannel(void)
 {
   Mixer_PlayChannel(audio.music_channel);
 
   if (mixer[audio.music_channel].type != MUS_TYPE_WAV)
   {
+    int loops = (IS_LOOP(mixer[audio.music_channel]) ? -1 : 1);
+
     // use short fade-in to prevent "plop" sound for certain music files
     // (this may happen when switching on music while playing the game)
     Mix_VolumeMusic(mixer[audio.music_channel].volume);
-    Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, -1, 100);
+    Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, loops, 100);
 
 #if defined(PLATFORM_WIN32)
     // playing MIDI music is broken since Windows Vista, as it sets the volume
@@ -249,7 +251,7 @@ static void Mixer_StopChannel(int channel)
   mixer_active_channels--;
 }
 
-static void Mixer_StopMusicChannel()
+static void Mixer_StopMusicChannel(void)
 {
   Mixer_StopChannel(audio.music_channel);
 
@@ -268,7 +270,7 @@ static void Mixer_FadeChannel(int channel)
   Mix_FadeOutChannel(channel, SOUND_FADING_INTERVAL);
 }
 
-static void Mixer_FadeMusicChannel()
+static void Mixer_FadeMusicChannel(void)
 {
   Mixer_FadeChannel(audio.music_channel);
 
@@ -652,13 +654,13 @@ void LoadCustomMusic_NoConf(void)
   draw_init_text = FALSE;
 }
 
-int getSoundListSize()
+int getSoundListSize(void)
 {
   return (sound_info->num_file_list_entries +
          sound_info->num_dynamic_file_list_entries);
 }
 
-int getMusicListSize()
+int getMusicListSize(void)
 {
   return (music_info->num_file_list_entries +
          music_info->num_dynamic_file_list_entries);
@@ -740,27 +742,27 @@ char *getMusicInfoEntryFilename(int pos)
   return getBaseNamePtr(mus_info->source_filename);
 }
 
-char *getCurrentlyPlayingMusicFilename()
+char *getCurrentlyPlayingMusicFilename(void)
 {
   return currently_playing_music_filename;
 }
 
-int getSoundListPropertyMappingSize()
+int getSoundListPropertyMappingSize(void)
 {
   return sound_info->num_property_mapping_entries;
 }
 
-int getMusicListPropertyMappingSize()
+int getMusicListPropertyMappingSize(void)
 {
   return music_info->num_property_mapping_entries;
 }
 
-struct PropertyMapping *getSoundListPropertyMapping()
+struct PropertyMapping *getSoundListPropertyMapping(void)
 {
   return sound_info->property_mapping;
 }
 
-struct PropertyMapping *getMusicListPropertyMapping()
+struct PropertyMapping *getMusicListPropertyMapping(void)
 {
   return music_info->property_mapping;
 }
@@ -923,6 +925,14 @@ void PlayMusic(int nr)
   PlaySoundMusic(nr);
 }
 
+void PlayMusicLoop(int nr)
+{
+  if (!audio.music_available)
+    return;
+
+  PlaySoundMusicLoop(nr);
+}
+
 void PlaySound(int nr)
 {
   if (!setup.sound_simple)
@@ -955,6 +965,14 @@ void PlaySoundMusic(int nr)
   PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC);
 }
 
+void PlaySoundMusicLoop(int nr)
+{
+  if (!setup.sound_music)
+    return;
+
+  PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC_LOOP);
+}
+
 void PlaySoundExt(int nr, int volume, int stereo_position, int state)
 {
   SoundControl snd_ctrl;
@@ -1000,12 +1018,12 @@ void FadeSound(int nr)
   StopSoundExt(nr, SND_CTRL_FADE_SOUND);
 }
 
-void FadeSounds()
+void FadeSounds(void)
 {
   StopSoundExt(-1, SND_CTRL_FADE_ALL);
 }
 
-void FadeSoundsAndMusic()
+void FadeSoundsAndMusic(void)
 {
   FadeSounds();
   FadeMusic();
@@ -1024,7 +1042,7 @@ void StopSound(int nr)
   StopSoundExt(nr, SND_CTRL_STOP_SOUND);
 }
 
-void StopSounds()
+void StopSounds(void)
 {
   StopMusic();
   StopSoundExt(-1, SND_CTRL_STOP_ALL);
@@ -1061,13 +1079,13 @@ void ExpireSoundLoops(boolean active)
   HandleSoundRequest(snd_ctrl);
 }
 
-static void ReloadCustomSounds()
+static void ReloadCustomSounds(void)
 {
   LoadArtworkConfig(sound_info);
   ReloadCustomArtworkList(sound_info);
 }
 
-static void ReloadCustomMusic()
+static void ReloadCustomMusic(void)
 {
   LoadArtworkConfig(music_info);
   ReloadCustomArtworkList(music_info);
@@ -1127,7 +1145,7 @@ void FreeMusic(void *ptr)
   free(music);
 }
 
-static void FreeAllMusic_NoConf()
+static void FreeAllMusic_NoConf(void)
 {
   int i;
 
@@ -1143,12 +1161,12 @@ static void FreeAllMusic_NoConf()
   num_music_noconf = 0;
 }
 
-void FreeAllSounds()
+void FreeAllSounds(void)
 {
   FreeCustomArtworkLists(sound_info);
 }
 
-void FreeAllMusic()
+void FreeAllMusic(void)
 {
   FreeCustomArtworkLists(music_info);
   FreeAllMusic_NoConf();