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);
if ((snd_info->data_ptr = Mix_LoadWAV(filename)) == NULL)
{
- Error(ERR_WARN, "cannot read sound file '%s'", filename);
+ Error(ERR_WARN, "cannot read sound file '%s': %s", filename, Mix_GetError());
free(snd_info);
return NULL;
}
if ((mod_info->data_ptr = Mix_LoadMUS(filename)) == NULL)
{
- Error(ERR_WARN, "cannot read music file '%s'", filename);
+ Error(ERR_WARN, "cannot read music file '%s': %s", filename, Mix_GetError());
free(mod_info);
return NULL;
}
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);