rnd-20020512-2-src
authorHolger Schemel <info@artsoft.org>
Sun, 12 May 2002 19:11:32 +0000 (21:11 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:37 +0000 (10:37 +0200)
src/libgame/sound.c
src/libgame/sound.h

index ceeee1477b532295520d29efda50b861118f410c..cb7dc63d92f96da122b9b2f22c22725ee912b324 100644 (file)
@@ -773,15 +773,26 @@ static void HandleSoundRequest(SoundControl snd_ctrl)
     SendSoundControlToMixerProcess(&snd_ctrl);
     return;
   }
-#elif defined(TARGET_SDL)
+#endif
+
   for (i=0; i<audio.num_channels; i++)
+  {
+    if (!mixer[i].active)
+      continue;
+
+    if (i != audio.music_channel &&
+       DelayReached(&mixer[i].playing_starttime, SOUND_LOOP_EXPIRATION_TIME))
+    {
+      Mixer_StopChannel(i);
+      continue;
+    }
+
+#if defined(TARGET_SDL)
+
     if (!Mix_Playing(i))
       Mixer_StopChannel(i);
+
 #elif defined(TARGET_ALLEGRO)
-  for (i=0; i<audio.num_channels; i++)
-  {
-    if (!mixer[i].active || IS_LOOP(mixer[i]))
-      continue;
 
     mixer[i].playing_pos = voice_get_position(mixer[i].voice);
     mixer[i].volume = voice_get_volume(mixer[i].voice);
@@ -789,8 +800,9 @@ static void HandleSoundRequest(SoundControl snd_ctrl)
     /* sound sample has completed playing or was completely faded out */
     if (mixer[i].playing_pos == -1 || mixer[i].volume == 0)
       Mixer_StopChannel(i);
-  }
+
 #endif /* TARGET_ALLEGRO */
+  }
 
   if (IS_RELOADING(snd_ctrl))          /* load new sound or music files */
   {
index db99a81d2a77f660a4503973488b4cea5ae39dd5..5350c14338022cfceeeacc46b4df8924b0b62afb 100644 (file)
@@ -65,6 +65,9 @@
 #define AUDIO_FORMAT_LE                                (1 << 2)
 #define AUDIO_FORMAT_BE                                (1 << 3)
 
+/* expiration time (in milliseconds) for sound loops */
+#define SOUND_LOOP_EXPIRATION_TIME             200
+
 #if defined(TARGET_SDL)
 /* one second fading interval == 1000 ticks (milliseconds) */
 #define SOUND_FADING_INTERVAL                  1000