/*
* call-seq:
* volume = new_vol
*
* Set the new #volume level of the music.
* 0.0 is totally silent, 1.0 is full volume.
*
* Volume cannot be set while the music is fading in or out.
* Be sure to check #fading? or rescue from SDLError when
* using this method.
*
* May raise:: SDLError if the music is fading in or out.
*
*/
static VALUE rg_music_setvolume( VALUE self, VALUE volume )
{
RG_Music *music;
Data_Get_Struct(self, RG_Music, music);
/* If the music is current, we'll change the current volume. */
if( _rg_music_current_check(self) )
{
/* But only if it's not fading right now. */
if( Mix_FadingMusic() == MIX_NO_FADING )
{
music->volume = NUM2DBL(volume);
Mix_VolumeMusic( (int)(MIX_MAX_VOLUME * music->volume) );
}
else
{
rb_raise(eSDLError, "cannot set Music volume while fading");
}
}
else
{
/* Save it for later. */
music->volume = NUM2DBL(volume);
}
return volume;
}