/*
* call-seq:
* fade_out( fade_time ) -> self
*
* Fade out to silence over the given number of seconds. Once the music
* is silent, it is automatically stopped.
*
* Returns:: The receiver (self).
*
* **NOTE**: If the music is currently paused, the fade will start,
* but you won't be able to hear it happening unless you #unpause during
* the fade.
*
* Does nothing if the music is currently stopped.
*
*/
static VALUE rg_music_fadeout( VALUE self, VALUE fade_time )
{
RG_Music *music;
Data_Get_Struct(self, RG_Music, music);
int fade_ms = (int)(1000 * NUM2DBL(fade_time));
if( fade_ms < 0 )
{
rb_raise(rb_eArgError, "fade_time cannot be negative (got %.2f)",
fade_ms / 1000);
}
/* Check that the music is current */
if( _rg_music_current_check(self) )
{
int result = Mix_FadeOutMusic( fade_ms );
if ( result < 0 )
{
rb_raise(eSDLError, "Error fading out music: %s", Mix_GetError());
}
}
return self;
}