added cropping text area gadgets that do not fit to the current viewport
[rocksndiamonds.git] / src / libgame / sound.c
index 4f5ddd0b2ca46fd741863cf36d9fa3d00b259ade..3d085a9dbe8f8f336d241978616723cbcb8ec465 100644 (file)
@@ -166,8 +166,8 @@ static boolean Mixer_ChannelExpired(int channel)
 
   if (expire_loop_sounds &&
       IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]) &&
-      DelayReached(&mixer[channel].playing_starttime,
-                  SOUND_LOOP_EXPIRATION_TIME))
+      DelayReachedExt2(&mixer[channel].playing_starttime,
+                      SOUND_LOOP_EXPIRATION_TIME, Counter()))
     return TRUE;
 
   if (!Mix_Playing(channel))
@@ -233,7 +233,7 @@ static void Mixer_PlayMusicChannel(void)
     Mix_VolumeMusic(mixer[audio.music_channel].volume);
     Mix_FadeInMusic(mixer[audio.music_channel].data_ptr, loops, 100);
 
-#if defined(PLATFORM_WIN32)
+#if defined(PLATFORM_WINDOWS)
     // playing MIDI music is broken since Windows Vista, as it sets the volume
     // for MIDI music also for all other sounds and music, which cannot be set
     // back to normal unless playing MIDI music again with that desired volume
@@ -281,7 +281,7 @@ static void Mixer_FadeMusicChannel(void)
 
   Mix_FadeOutMusic(SOUND_FADING_INTERVAL);
 
-#if defined(PLATFORM_WIN32)
+#if defined(PLATFORM_WINDOWS)
   // playing MIDI music is broken since Windows Vista, as it sets the volume
   // for MIDI music also for all other sounds and music, which cannot be set
   // back to normal unless playing MIDI music again with that desired volume
@@ -409,8 +409,8 @@ static void Mixer_InsertSound(SoundControl snd_ctrl)
     {
       if (!mixer[i].active)
       {
-       Error(ERR_INFO, "Mixer_InsertSound: Channel %d inactive", i);
-       Error(ERR_INFO, "Mixer_InsertSound: This should never happen!");
+       Debug("audio", "Mixer_InsertSound: Channel %d inactive", i);
+       Debug("audio", "Mixer_InsertSound: This should never happen!");
 
        mixer_active_channels--;
       }
@@ -538,8 +538,10 @@ static void *Load_WAV(char *filename)
 
   if ((snd_info->data_ptr = Mix_LoadWAV(filename)) == NULL)
   {
-    Error(ERR_WARN, "cannot read sound file '%s': %s", filename, Mix_GetError());
+    Warn("cannot read sound file '%s': %s", filename, Mix_GetError());
+
     free(snd_info);
+
     return NULL;
   }
 
@@ -562,8 +564,10 @@ static void *Load_MOD(char *filename)
 
   if ((mod_info->data_ptr = Mix_LoadMUS(filename)) == NULL)
   {
-    Error(ERR_WARN, "cannot read music file '%s': %s", filename, Mix_GetError());
+    Warn("cannot read music file '%s': %s", filename, Mix_GetError());
+
     free(mod_info);
+
     return NULL;
   }
 
@@ -587,7 +591,7 @@ static void LoadCustomMusic_NoConf(void)
 {
   static boolean draw_init_text = TRUE;                // only draw at startup
   static char *last_music_directory = NULL;
-  char *music_directory = getCustomMusicDirectory();
+  char *music_directory = getCustomMusicDirectory_NoConf();
   Directory *dir;
   DirectoryEntry *dir_entry;
   int num_music = getMusicListSize();
@@ -607,7 +611,7 @@ static void LoadCustomMusic_NoConf(void)
 
   if ((dir = openDirectory(music_directory)) == NULL)
   {
-    Error(ERR_WARN, "cannot read music directory '%s'", music_directory);
+    Warn("cannot read music directory '%s'", music_directory);
 
     audio.music_available = FALSE;
 
@@ -615,7 +619,7 @@ static void LoadCustomMusic_NoConf(void)
   }
 
   if (draw_init_text)
-    DrawInitText("Loading music", 120, FC_GREEN);
+    DrawInitTextHead("Loading music");
 
   while ((dir_entry = readDirectory(dir)) != NULL)     // loop all entries
   {
@@ -640,7 +644,7 @@ static void LoadCustomMusic_NoConf(void)
       continue;
 
     if (draw_init_text)
-      DrawInitText(basename, 150, FC_YELLOW);
+      DrawInitTextItem(basename);
 
     if (FileIsMusic(dir_entry->filename))
       mus_info = Load_WAV_or_MOD(dir_entry->filename);
@@ -737,6 +741,16 @@ static MusicInfo *getMusicInfoEntryFromMusicID(int pos)
   return mus_info[list_pos];
 }
 
+char *getSoundInfoEntryFilename(int pos)
+{
+  SoundInfo *snd_info = getSoundInfoEntryFromSoundID(pos);
+
+  if (snd_info == NULL)
+    return NULL;
+
+  return getBaseNamePtr(snd_info->source_filename);
+}
+
 char *getMusicInfoEntryFilename(int pos)
 {
   MusicInfo *mus_info = getMusicInfoEntryFromMusicID(pos);
@@ -1099,7 +1113,7 @@ static void ReloadCustomMusic(void)
   LoadCustomMusic_NoConf();
 }
 
-void InitReloadCustomSounds(char *set_identifier)
+void InitReloadCustomSounds(void)
 {
   if (!audio.sound_available)
     return;
@@ -1107,7 +1121,7 @@ void InitReloadCustomSounds(char *set_identifier)
   ReloadCustomSounds();
 }
 
-void InitReloadCustomMusic(char *set_identifier)
+void InitReloadCustomMusic(void)
 {
   if (!audio.music_available)
     return;