#include <akgltest.h>

akerr_ErrorContext AKERR_NOIGNORE *music_toggle(akgl_Actor *obj, SDL_Event *event)
{
    SDL_PropertiesID bgmprops = 0;
    PREPARE_ERROR(e);
    if ( MIX_TrackPlaying(akgl_tracks[AKGL_GAME_AUDIO_TRACK_BGM]) ) {
	FAIL_ZERO_RETURN(
	    e,
	    MIX_StopTrack(akgl_tracks[AKGL_GAME_AUDIO_TRACK_BGM], 0),
	    AKGL_ERR_SDL,
	    "%s",
	    SDL_GetError());
    } else {
	SDL_SetNumberProperty(bgmprops, MIX_PROP_PLAY_LOOPS_NUMBER, -1);
	FAIL_ZERO_RETURN(
	    e,
	    MIX_PlayTrack(akgl_tracks[AKGL_GAME_AUDIO_TRACK_BGM], bgmprops),
	    AKGL_ERR_SDL,
	    "%s",
	    SDL_GetError());
    }
    SUCCEED_RETURN(e);
}
