2010-10-18 15:07:55 +08:00
|
|
|
#ifndef _SOUND_DATA_MANAGER_H_
|
|
|
|
#define _SOUND_DATA_MANAGER_H_
|
|
|
|
|
|
|
|
#include <map>
|
2010-10-21 10:21:24 +08:00
|
|
|
#include "uthash.h"
|
2010-10-21 14:44:02 +08:00
|
|
|
#include <string>
|
2011-01-11 16:41:06 +08:00
|
|
|
#include "TG3.h"
|
2010-10-18 15:07:55 +08:00
|
|
|
|
2010-12-15 18:28:18 +08:00
|
|
|
namespace CocosDenshion {
|
|
|
|
|
2010-11-12 16:33:50 +08:00
|
|
|
/**
|
|
|
|
@struct tEffectElement
|
|
|
|
@brief The struct of hash table elements
|
|
|
|
*/
|
2010-10-18 15:07:55 +08:00
|
|
|
typedef struct _hashElement
|
|
|
|
{
|
2011-01-11 16:41:06 +08:00
|
|
|
char FileName[MAX_PATH];
|
2010-10-18 15:07:55 +08:00
|
|
|
unsigned char* pDataBuffer;
|
|
|
|
int nDataSize;
|
|
|
|
UT_hash_handle hh;
|
|
|
|
} tEffectElement;
|
|
|
|
|
2010-11-12 16:33:50 +08:00
|
|
|
/**
|
|
|
|
@class SoundDataManager
|
|
|
|
@brief The manager of sound data
|
|
|
|
*/
|
2010-10-18 15:07:55 +08:00
|
|
|
class SoundDataManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SoundDataManager();
|
|
|
|
~SoundDataManager();
|
|
|
|
|
2010-11-12 16:33:50 +08:00
|
|
|
/**
|
|
|
|
@brief Load the sound data
|
|
|
|
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
|
|
|
*/
|
2011-01-11 16:41:06 +08:00
|
|
|
void loadSoundData(const char* pszFilePath);
|
2010-11-12 16:33:50 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Get the sound data by SoundID
|
2011-01-11 16:41:06 +08:00
|
|
|
@param pFileName The sound file name(have the path)
|
2010-11-12 16:33:50 +08:00
|
|
|
@return If find succeed,return the pointer of hash table element;or return NULL
|
|
|
|
*/
|
2011-01-11 16:41:06 +08:00
|
|
|
tEffectElement* getSoundData(const char* pFileName);
|
2010-10-18 15:07:55 +08:00
|
|
|
|
2010-11-12 16:33:50 +08:00
|
|
|
/**
|
|
|
|
@brief Unload the sound effect element by SoundID
|
2011-01-11 16:41:06 +08:00
|
|
|
@param pFileName The sound file name(have the path)
|
2010-11-12 16:33:50 +08:00
|
|
|
*/
|
2011-01-11 16:41:06 +08:00
|
|
|
void unloadEffect(const char* pFileName);
|
2010-11-12 16:33:50 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief Unload all effect elements
|
|
|
|
*/
|
2010-10-18 15:07:55 +08:00
|
|
|
void removeAllEffects();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// use hash map to save the effects loaded
|
|
|
|
struct _hashElement * m_pEffects;
|
|
|
|
};
|
|
|
|
|
2010-12-15 18:28:18 +08:00
|
|
|
} // end of namespace CocosDenshion
|
|
|
|
|
2010-10-18 15:07:55 +08:00
|
|
|
#endif
|