2010-10-18 15:07:55 +08:00
|
|
|
#ifndef _SOUND_DATA_MANAGER_H_
|
|
|
|
#define _SOUND_DATA_MANAGER_H_
|
|
|
|
|
2010-10-21 10:21:24 +08:00
|
|
|
#include "ResourceHandle.h"
|
2010-10-18 15:07:55 +08:00
|
|
|
#include <map>
|
2010-10-21 10:21:24 +08:00
|
|
|
#include "uthash.h"
|
|
|
|
#include "SimpleAudioEngine.h"
|
2010-10-21 14:44:02 +08:00
|
|
|
#include <string>
|
2010-10-18 15:07:55 +08:00
|
|
|
|
|
|
|
typedef struct _hashElement
|
|
|
|
{
|
|
|
|
int nSoundID;
|
|
|
|
unsigned char* pDataBuffer;
|
2010-10-21 10:21:24 +08:00
|
|
|
const char* FileName;
|
2010-10-18 15:07:55 +08:00
|
|
|
int nDataSize;
|
2010-11-11 11:18:58 +08:00
|
|
|
int nPlayerSoundID;
|
2010-10-18 15:07:55 +08:00
|
|
|
UT_hash_handle hh;
|
|
|
|
} tEffectElement;
|
|
|
|
|
|
|
|
class SoundDataManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SoundDataManager();
|
|
|
|
~SoundDataManager();
|
|
|
|
|
|
|
|
void setResEntry(const void* pResEntry);
|
|
|
|
void setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount);
|
|
|
|
|
|
|
|
int loadSoundData(const char* pszFilePath);
|
|
|
|
tEffectElement* getSoundData(int nSoundID);
|
|
|
|
|
|
|
|
void unloadEffect(int nSoundID);
|
|
|
|
void removeAllEffects();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int loadFromResourceInfo(const char* pFileKey);
|
|
|
|
int loadFromFile(const char* pFilePath);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ResourceHandle* m_pHRes;
|
|
|
|
|
|
|
|
// use hash map to save the effects loaded
|
|
|
|
struct _hashElement * m_pEffects;
|
|
|
|
|
|
|
|
typedef std::map<std::string, int> SoundInfoMap;
|
|
|
|
SoundInfoMap* m_pSoundMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|