mixer.c
changeset 696 9599bb0ff844
parent 694 59ef72d7586d
child 710 1aca2b6d570f
equal deleted inserted replaced
695:6a5e6d8d6a35 696:9599bb0ff844
   318     }
   318     }
   319 
   319 
   320     /* Mix any playing channels... */
   320     /* Mix any playing channels... */
   321     sdl_ticks = SDL_GetTicks();
   321     sdl_ticks = SDL_GetTicks();
   322     for ( i=0; i<num_channels; ++i ) {
   322     for ( i=0; i<num_channels; ++i ) {
   323         if( ! mix_channel[i].paused ) {
   323         if ( !mix_channel[i].paused ) {
   324             if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
   324             if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
   325                 /* Expiration delay for that channel is reached */
   325                 /* Expiration delay for that channel is reached */
   326                 mix_channel[i].playing = 0;
   326                 mix_channel[i].playing = 0;
   327                 mix_channel[i].looping = 0;
   327                 mix_channel[i].looping = 0;
   328                 mix_channel[i].fading = MIX_NO_FADING;
   328                 mix_channel[i].fading = MIX_NO_FADING;
   329                 mix_channel[i].expire = 0;
   329                 mix_channel[i].expire = 0;
   330                 _Mix_channel_done_playing(i);
   330                 _Mix_channel_done_playing(i);
   331             } else if ( mix_channel[i].fading != MIX_NO_FADING ) {
   331             } else if ( mix_channel[i].fading != MIX_NO_FADING ) {
   332                 Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
   332                 Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
   333                 if( ticks > mix_channel[i].fade_length ) {
   333                 if ( ticks >= mix_channel[i].fade_length ) {
   334                     Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
   334                     Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
   335                     if( mix_channel[i].fading == MIX_FADING_OUT ) {
   335                     if( mix_channel[i].fading == MIX_FADING_OUT ) {
   336                         mix_channel[i].playing = 0;
   336                         mix_channel[i].playing = 0;
   337                         mix_channel[i].looping = 0;
   337                         mix_channel[i].looping = 0;
   338                         mix_channel[i].expire = 0;
   338                         mix_channel[i].expire = 0;
   339                         _Mix_channel_done_playing(i);
   339                         _Mix_channel_done_playing(i);
   340                     }
   340                     }
   341                     mix_channel[i].fading = MIX_NO_FADING;
   341                     mix_channel[i].fading = MIX_NO_FADING;
   342                 } else {
   342                 } else {
   343                     if( mix_channel[i].fading == MIX_FADING_OUT ) {
   343                     if ( mix_channel[i].fading == MIX_FADING_OUT ) {
   344                         Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
   344                         Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
   345                                    / mix_channel[i].fade_length );
   345                                    / mix_channel[i].fade_length );
   346                     } else {
   346                     } else {
   347                         Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length );
   347                         Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length );
   348                     }
   348                     }
  1092             if ( mix_channel[which].playing &&
  1092             if ( mix_channel[which].playing &&
  1093                 (mix_channel[which].volume > 0) &&
  1093                 (mix_channel[which].volume > 0) &&
  1094                 (mix_channel[which].fading != MIX_FADING_OUT) ) {
  1094                 (mix_channel[which].fading != MIX_FADING_OUT) ) {
  1095                 mix_channel[which].fade_volume = mix_channel[which].volume;
  1095                 mix_channel[which].fade_volume = mix_channel[which].volume;
  1096                 mix_channel[which].fading = MIX_FADING_OUT;
  1096                 mix_channel[which].fading = MIX_FADING_OUT;
  1097                 mix_channel[which].fade_length = ms;
  1097                 mix_channel[which].fade_length = (Uint32)ms;
  1098                 mix_channel[which].ticks_fade = SDL_GetTicks();
  1098                 mix_channel[which].ticks_fade = SDL_GetTicks();
  1099 
  1099 
  1100                 /* only change fade_volume_reset if we're not fading. */
  1100                 /* only change fade_volume_reset if we're not fading. */
  1101                 if (mix_channel[which].fading == MIX_NO_FADING) {
  1101                 if (mix_channel[which].fading == MIX_NO_FADING) {
  1102                     mix_channel[which].fade_volume_reset = mix_channel[which].volume;
  1102                     mix_channel[which].fade_volume_reset = mix_channel[which].volume;