2011-10-14 18:33:14 +08:00
|
|
|
#ifndef __CCAUDIOOUT_H__
|
|
|
|
#define __CCAUDIOOUT_H__
|
2011-10-18 18:10:53 +08:00
|
|
|
|
2011-10-14 17:57:44 +08:00
|
|
|
#include <FBase.h>
|
|
|
|
#include <FMedia.h>
|
2011-10-18 09:45:04 +08:00
|
|
|
#include <FIo.h>
|
2011-10-14 17:57:44 +08:00
|
|
|
|
2011-10-18 09:45:04 +08:00
|
|
|
namespace CocosDenshion {
|
|
|
|
|
|
|
|
class CCAudioOut:
|
2011-10-14 17:57:44 +08:00
|
|
|
public Osp::Media::IAudioOutEventListener
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2011-10-18 09:45:04 +08:00
|
|
|
CCAudioOut();
|
|
|
|
virtual ~CCAudioOut();
|
2011-10-14 17:57:44 +08:00
|
|
|
|
|
|
|
virtual void OnAudioOutBufferEndReached(Osp::Media::AudioOut& src);
|
|
|
|
virtual void OnAudioOutInterrupted(Osp::Media::AudioOut& src);
|
|
|
|
virtual void OnAudioOutReleased(Osp::Media::AudioOut& src);
|
|
|
|
|
2011-10-18 09:45:04 +08:00
|
|
|
int DecodeOgg(const char *infile);
|
|
|
|
result Initialize(const char* pszFilePath);
|
|
|
|
result FeedBuffer (void);
|
2011-10-18 18:10:53 +08:00
|
|
|
result ReWriteBuffer(void);
|
2011-10-18 09:45:04 +08:00
|
|
|
void ReFeedBuffer(void);
|
|
|
|
void Finalize(void);
|
|
|
|
|
2011-10-18 18:10:53 +08:00
|
|
|
result Play(void);
|
|
|
|
result Stop(void);
|
|
|
|
result Reset(void);
|
2011-10-18 09:45:04 +08:00
|
|
|
void SetVolume(int volume);
|
2011-10-18 18:10:53 +08:00
|
|
|
int GetVolume(void) const;
|
|
|
|
Osp::Media::AudioOutState GetState(void) const;
|
2011-10-14 17:57:44 +08:00
|
|
|
private:
|
2011-10-18 09:45:04 +08:00
|
|
|
Osp::Media::AudioOut *__pAudioOut;
|
|
|
|
Osp::Base::ByteBuffer __byteBuffer [4];
|
2011-10-18 18:10:53 +08:00
|
|
|
bool __bBufferConstruted;
|
|
|
|
int __iUsedBufferCount;
|
2011-10-18 09:45:04 +08:00
|
|
|
Osp::Io::File *__pFile;
|
|
|
|
Osp::Media::AudioChannelType __sampleChannelType;
|
|
|
|
Osp::Media::AudioSampleType __sampleBitdepth;
|
|
|
|
bool __checkInitFiniPair;
|
|
|
|
int __bufferSize;
|
|
|
|
int __finishChecker;
|
|
|
|
int __buffWriteCnt;
|
|
|
|
int __buffReadCnt;
|
|
|
|
int __bufWrittenCnt;
|
|
|
|
int __volumeLevel;
|
2011-10-18 18:10:53 +08:00
|
|
|
bool __bShortPcmBuffer;
|
2011-10-18 09:45:04 +08:00
|
|
|
|
|
|
|
int __iFileType; // 0: wav; 1:ogg
|
|
|
|
int __sampleRate;
|
|
|
|
char* __pAllPcmBuffer;
|
|
|
|
int __iAllPcmBufferSize;
|
|
|
|
int __iAllPcmPos;
|
|
|
|
int quiet;
|
|
|
|
int bits;
|
|
|
|
int endian;
|
|
|
|
int raw;
|
|
|
|
int sign;
|
2011-10-14 17:57:44 +08:00
|
|
|
};
|
|
|
|
|
2011-10-18 09:45:04 +08:00
|
|
|
}
|
2011-10-18 18:10:53 +08:00
|
|
|
|
2011-10-18 09:45:04 +08:00
|
|
|
#endif /* __CCAUDIOOUT_H__ */
|