From: Holger Schemel Date: Sat, 10 Feb 2024 20:25:18 +0000 (+0100) Subject: added using callback function when sound channel is finished X-Git-Tag: 4.4.0.0-test-1~413 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=58f87f14af2c55cfe04c5b66fcede7876f16ef25;p=rocksndiamonds.git added using callback function when sound channel is finished --- diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 473850dd..f911d238 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -141,6 +141,15 @@ static MusicInfo *getMusicInfoEntryFromMusicID(int); // mixer functions // ---------------------------------------------------------------------------- +static void Mixer_ChannelFinished(int channel) +{ + if (!mixer[channel].active) + return; + + mixer[channel].active = FALSE; + mixer_active_channels--; +} + void Mixer_InitChannels(void) { int i; @@ -148,6 +157,8 @@ void Mixer_InitChannels(void) for (i = 0; i < audio.num_channels; i++) mixer[i].active = FALSE; mixer_active_channels = 0; + + Mix_ChannelFinished(Mixer_ChannelFinished); } static void Mixer_ResetChannelExpiration(int channel) @@ -247,13 +258,7 @@ static void Mixer_PlayMusicChannel(void) static void Mixer_StopChannel(int channel) { - if (!mixer[channel].active) - return; - Mix_HaltChannel(channel); - - mixer[channel].active = FALSE; - mixer_active_channels--; } static void Mixer_StopMusicChannel(void)