//
// Asura_Wii_Sound.h
//
// Created by KOR - 09 July 2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_WII_SOUND_H__
#define __ASURA_WII_SOUND_H__

// Asura 
#include "Sound/Asura_Sound.h"

// Asura Wii
//#include "Bink/Asura_Bink.h"
#include "Sound/Asura_AX.h"
#include "Sound/Asura_Wii_StreamSound.h"



const u_int uASURA_WII_SOUND_MAX_FILES = 4;
const u_int uASURA_WII_SOUND_MAX_FILENAME = 128;

enum Asura_Wii_Sound_LoadStatus
{
	Asura_Wii_Sound_Not_Loaded = 0,
	Asura_Wii_Sound_Loaded_Perm,
	Asura_Wii_Sound_Loaded_Temp,
	Asura_Wii_Sound_Stream_Offset_Loaded,
};

struct Asura_Wii_Sound_File_Data
{
	u_int	m_uOffset;
	u_int	m_uSize;
	int		m_iFileIndex;
};

class Asura_Wii_Sound_Filename_Entry
{
public:
	Asura_Wii_Sound_Filename_Entry();

	int GetDVDEntryNum() const { return m_iDVDEntryNum; }
	void SetFilename(const char* szFilename);
private:
	int		m_iDVDEntryNum;
	char	m_szFilename[uASURA_WII_SOUND_MAX_FILENAME];
};

class Asura_Wii_Sound
{
public:
	static int  Initialise();
	static void Shutdown();
	static void Update();
	static void Reset();
	static void SetResetPoint();
	static bool LoadSound(const char* szFilename, int iIndex);
	static bool LoadSoundFromResource(Asura_Handle iFileHandle, int iFileSize, int iLoadedSoundIndex);
	static bool UnloadSound(const int iLoadedSoundIndex);
	static bool CreateSound(int iLoadedSoundIndex, Asura_Handle iSoundHandle, bool bUseEQ, bool bUseHardware3dPan);
	static bool PlaySound(Asura_Handle iSoundHandle, bool bLooping);
	static bool StopSound(Asura_Handle iSoundHandle);
	static bool DestroySound(Asura_Handle iSoundHandle);
	static bool IsSoundPlaying(Asura_Handle iSoundHandle);
	static bool SetSoundVolumePanAndFade(Asura_Handle iSoundHandle, float fVolume, float fPan, float fFade);
	static bool SetSoundPitch(Asura_Handle iSoundHandle, float fPitch);
	static bool PauseSound(Asura_Handle iSoundHandle);
	static bool UnpauseSound(Asura_Handle iSoundHandle);
	static void InitStreamedSounds(const char* szFilename);
	static void AddStreamingSoundData(int iSoundID, int iOffset, int iSize, Asura_Hash_ID uSoundHash);
	static void StreamingSoundCallback();

private:
	// Filename tracking
	static Asura_Wii_Sound_Filename_Entry s_axSoundFilenames[uASURA_WII_SOUND_MAX_FILES];
	static u_int						s_uNumFilenames;
	static u_int						s_uPermanentFilenames;
	static Asura_Wii_Sound_LoadStatus	s_axSoundLoadStatus[ASURA_MAX_NUMBER_OF_LOADED_SOUNDS];
	static Asura_Wii_Sound_File_Data	s_axSoundFileData[ASURA_MAX_NUMBER_OF_LOADED_SOUNDS];
	// DSP-ADPCM in ARAM = true, stream = false
	static bool							s_abActiveSoundInMemory[ASURA_WII_MAX_NUMBER_OF_ACTIVE_SOUNDS];
	static Asura_Wii_Streaming_Sound	s_axActiveStreams[ASURA_WII_MAX_NUMBER_OF_ACTIVE_SOUNDS];

};

#endif//__ASURA_WII_SOUND_H__