#include "quakedef.h"

int SelectTrack (void)
{
	if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
		return cls.forcetrack;
	else
		return cl.cdtrack;
}

void SAPI_Shutdown (void)
{
	FMOD_Shutdown();
}

void SAPI_Init (void)
{
	FMOD_Init();
}

void SAPI_StartMusic (void)
{
	char track_name[32];

	if (!sv.active)
		sprintf(track_name, "music/menu");
	else if (!strnicmp (sv.name, "keep",4) ||
		!strnicmp (sv.name, "monsters",8) ||
		!strnicmp (sv.name, "thomas",6) ||
		!strnicmp (sv.name, "tibet",5))
		sprintf(track_name, "music/portal/track%02i", SelectTrack());
	else
		sprintf(track_name, "music/hexen2/track%02i", SelectTrack());
	FMOD_StartMusic(track_name, true, false, false); //char *name, qboolean loop, qboolean notify, qboolean resume
}

void SAPI_StopMusic (void)
{
	FMOD_StopMusic();
}

void SAPI_PauseMusic (void)
{
	FMOD_PauseMusic();
}
void SAPI_ResumeMusic (void)
{
	FMOD_ResumeMusic();
}

void SAPI_UpdateMusic (void)
{
	FMOD_UpdateMusic();
}