代码如下: 未完待续 /* 02.22.2009 ccsdu2004@yahoo.com.cn www.gaimo.net this file */ #include <string> #include <map> #include <boost/scoped_ptr.hpp> #include <zthread/zthread.h> using namespace std; using namespace boost; using namespace ZThread; //enumated all supported audio interface. enum AUDIO { AUDIO_OPENAL }; //class AudioManger is one for manger all audio object. //when connerned with filename, there will be lower char for operation. class AudioManager { pulic: //set and get player attributes. void SetPlayerPosition(float x, float y, float z); void SetPlayerVelocity(float vx, float vy, float vz); void GetPlayerPosition(float x, float y, float z); void GetPlayerVelocity(float *vx,float *vy,float *vz); public: //set and get listener attributes. void SetListenerPosition(float x, float y, float z); void SetListenerVelocity(float vx, float vy, float vz); void SetListenerDirection(float x, float y, float z); void GetListenerPosition(float *x, float *y, float *z); void GetListenerVelocity(float *vx, float *vy, float *vz); void GetListenerDirection(float *x, float *y, float *z); public: //set and get audio path bool SetAudioPath(const string &path); //set supported file suffix //parameter suffix'sformat is that - " .map .wav" .like that. bool SetFileSuffix(const string &suffix); //adjust file list. bool RemoveFile(const string &file); public: //init audio interface before using the class bool Init(AUDIO audio); void Shutdown(); void Update(unsigned int time); public: void Stop(); void Stop(const string &name); void Rewind(const string &name); bool IsPlay(const string &name); bool IsStop(const string &name); bool SetGain(float gain); float GetGain(); //void SetFeq(unsigned int feq) //unsigned int GetFeq();; public: unsigned int GetAllTime(const string &name); unsigned int GetPlayTime(const string &name); float GetPlayPercent(const string &name); public: void OpenThread(bool open); bool CloseTread(); void UpdateThread(); private: void WorkThread(); void CannelThread(); private: bool threadWork; bool callThread; private: scoped_ptr<Zthread*> threadPtr; scoped_ptr<SourceMap*> sourcePtr; scoped_ptr<BufferMap*> bufferPtr; private: //audio name and its source typedef map<string, AudioSource*> SourceMap; typedef map<string, AudioSource*>::iterator SourceMapItr; //auio file and tis buffer. typedef pair<AudioFile*,AudioBuffer*> BufferPair; //audio name and its buffer pair. typedef map<string, BufferPair> BufferMap; typedef map<string, BufferPair>::iterator BufferMapItr; };