Mix_ChannelFinished?

the new SDL_mixer has the Mix_ChannelFinished, which can give me a
callback when a channel finished playing. i’m wondering if this is
"guaranteed" to be called under all circumstances. For example, is every
call to “Mix_Play*” going to generate a trip to my callback?

i’m probably going to need to dig through the source on this one to be
sure, but if things were designed to work like this, it would really
help me out.

the new SDL_mixer has the Mix_ChannelFinished, which can give me a
callback when a channel finished playing. i’m wondering if this is
"guaranteed" to be called under all circumstances. For example, is every
call to “Mix_Play*” going to generate a trip to my callback?

Every time a sound hits the end of its playback, the associated "finished"
callback is called.

This includes premature termination of the sound through Mix_HaltChannel().

–ryan.

Just curious… does the callback also occur if the sound in that channel
is replaced with a new sound (either my specifically playing a new sound
on the channel, or by playing a new sound and letting SDL_mixer pick the
channel to play on (-1)), or is it simply when the channel once again
becomes ‘silent’?

-bill!On Fri, Jan 11, 2002 at 10:56:30PM -0500, Ryan C. Gordon wrote:

the new SDL_mixer has the Mix_ChannelFinished, which can give me a
callback when a channel finished playing. i’m wondering if this is
"guaranteed" to be called under all circumstances. For example, is every
call to “Mix_Play*” going to generate a trip to my callback?

Every time a sound hits the end of its playback, the associated "finished"
callback is called.

This includes premature termination of the sound through Mix_HaltChannel().

Just curious… does the callback also occur if the sound in that channel
is replaced with a new sound (either my specifically playing a new sound
on the channel, or by playing a new sound and letting SDL_mixer pick the
channel to play on (-1)), or is it simply when the channel once again
becomes ‘silent’?

Mix_PlayChannel*(-1) will not replace playing sounds (it reports failure
if there are no open channels). This is true for Mix_FadeInChannel*(), too.

As for whether the callback is called when replacing a SPECIFIC channel,
er…it is with this patch. :slight_smile:

–ryan.

Index: mixer.c===================================================================
RCS file: /home/slouken/libsdl.org/cvs/SDL_mixer/mixer.c,v
retrieving revision 1.32
diff -u -r1.32 mixer.c
— mixer.c 2001/12/17 21:26:38 1.32
+++ mixer.c 2002/01/13 21:08:47
@@ -620,6 +620,8 @@

	/* Queue up the audio data for this channel */
	if ( which >= 0 ) {
  •   	if (Mix_Playing(which))
    
  •   		Mix_ChannelDonePlaying(which);
      	Uint32 sdl_ticks = SDL_GetTicks();
      	mix_channel[which].samples = chunk->abuf;
      	mix_channel[which].playing = chunk->alen;
    

@@ -684,6 +686,8 @@

	/* Queue up the audio data for this channel */
	if ( which >= 0 ) {
  •   	if (Mix_Playing(which))
    
  •   		Mix_ChannelDonePlaying(which);
      	Uint32 sdl_ticks = SDL_GetTicks();
      	mix_channel[which].samples = chunk->abuf;
      	mix_channel[which].playing = chunk->alen;

Ryan C. Gordon wrote:

As for whether the callback is called when replacing a SPECIFIC channel,
er…it is with this patch. :slight_smile:

excellent! i look forward to the coming SDL_mixer release :]
(assuming all patches get applied)

Ryan C. Gordon wrote:

As for whether the callback is called when replacing a SPECIFIC channel,
er…it is with this patch. :slight_smile:

excellent! i look forward to the coming SDL_mixer release :]
(assuming all patches get applied)

They usually do. If something slips by, please remind me.

This patch got in. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment