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();
{
mixer[channel].playing_starttime = Counter();
- if (IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]))
+ if (expire_loop_sounds &&
+ IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]))
Mix_ExpireChannel(channel, SOUND_LOOP_EXPIRATION_TIME);
}
if (!mixer[channel].active)
return TRUE;
- if (IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]) &&
+ if (expire_loop_sounds &&
+ IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]) &&
DelayReached(&mixer[channel].playing_starttime,
SOUND_LOOP_EXPIRATION_TIME))
return TRUE;
if (SAME_SOUND_NR(mixer[i], snd_ctrl) || ALL_SOUNDS(snd_ctrl))
Mixer_StopChannel(i);
}
+ else if (SET_EXPIRE_LOOPS(snd_ctrl)) /* set loop expiration on or off */
+ {
+ expire_loop_sounds = snd_ctrl.active;
+ }
else if (snd_ctrl.active) /* add new sound to mixer */
{
Mixer_InsertSound(snd_ctrl);
HandleSoundRequest(snd_ctrl);
}
+void ExpireSoundLoops(boolean active)
+{
+ SoundControl snd_ctrl;
+
+ if (!audio.sound_available)
+ return;
+
+ clear_mem(&snd_ctrl, sizeof(SoundControl)); /* to make valgrind happy */
+
+ snd_ctrl.active = active;
+ snd_ctrl.state = SND_CTRL_EXPIRE_LOOPS;
+
+ HandleSoundRequest(snd_ctrl);
+}
+
static void ReloadCustomSounds()
{
LoadArtworkConfig(sound_info);
#define SND_CTRL_ALL_SOUNDS (1 << 4)
#define SND_CTRL_RELOAD_SOUNDS (1 << 5)
#define SND_CTRL_RELOAD_MUSIC (1 << 6)
+#define SND_CTRL_EXPIRE_LOOPS (1 << 7)
#define SND_CTRL_PLAY_SOUND (SND_CTRL_NONE)
#define SND_CTRL_PLAY_LOOP (SND_CTRL_LOOP)
#define IS_RELOADING(x) ((x).state & (SND_CTRL_RELOAD_SOUNDS |\
SND_CTRL_RELOAD_MUSIC))
#define ALL_SOUNDS(x) ((x).state & SND_CTRL_ALL_SOUNDS)
+#define SET_EXPIRE_LOOPS(x) ((x).state & SND_CTRL_EXPIRE_LOOPS)
#define MAP_NOCONF_MUSIC(x) (-((x) + 1))
#define UNMAP_NOCONF_MUSIC(x) MAP_NOCONF_MUSIC(x)
void StopSound(int);
void StopSounds(void);
void StopSoundExt(int, int);
+void ExpireSoundLoops(boolean);
int getSoundListSize();
int getMusicListSize();