//-----------------------------------------------------------------------------------------------
// Audio.hpp
//
#pragma once
#ifndef INCLUDED_AUDIO
#define INCLUDED_AUDIO
#include "Engine/Core/PlatformDefines.hpp"
#if defined( GYPSY_ENABLE_AUDIO )

//---------------------------------------------------------------------------
#pragma comment( lib, "../../../GypsyEngine/Code/ThirdParty/fmod/fmodex_vc" ) // Link in the fmodex_vc.lib static library


//---------------------------------------------------------------------------
#include "Engine/Core/EngineSubsystem.hpp"
#include "ThirdParty/fmod/fmod.hpp"
// #include <string>
// #include <vector>
// #include <map>


//---------------------------------------------------------------------------
typedef unsigned int SoundID;
typedef void* AudioChannelHandle;
const unsigned int MISSING_SOUND_ID = 0xffffffff;


/////////////////////////////////////////////////////////////////////////////
class AudioSystem : public EngineSubsystem
{
public:
	static void Create();

public:
	SoundID CreateOrGetSound( const std::string& soundFileName );
	AudioChannelHandle PlaySound( SoundID soundID, float volumeLevel=1.f );
	void StopChannel( AudioChannelHandle channel );
	virtual void BeginFrame();

protected:
	AudioSystem();
	virtual ~AudioSystem();
	virtual void StartUp();
	void InitializeFMOD();
	void ValidateResult( FMOD_RESULT result );

protected:
	FMOD::System*						m_fmodSystem;
	std::map< std::string, SoundID >	m_registeredSoundIDs;
	std::vector< FMOD::Sound* >			m_registeredSounds;
};


//---------------------------------------------------------------------------
void InitializeAudio();


//-----------------------------------------------------------------------------------------------
extern AudioSystem* theAudioSystem;


#endif // GYPSY_ENABLE_AUDIO
#endif // INCLUDED_AUDIO
