From b2c7bb0b283dd2a80f345e26c042d6ffaf05209c Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 22 Jul 2018 12:28:03 +0800 Subject: update --- src/libjin/audio/sdl/source.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/libjin/audio/sdl/source.h') diff --git a/src/libjin/audio/sdl/source.h b/src/libjin/audio/sdl/source.h index 365d6ff..ff311b6 100644 --- a/src/libjin/audio/sdl/source.h +++ b/src/libjin/audio/sdl/source.h @@ -14,6 +14,7 @@ namespace audio { typedef struct SDLSourceCommand; + class SDLSourceManager; class SDLSource : public Source { @@ -39,33 +40,33 @@ namespace audio bool setLoop(bool loop) override; void setRate(float rate) override; + inline void handle(SDLSourceManager* manager, SDLSourceCommand* cmd); + inline void process(void* buffer, size_t size); + private: SDLSource(); - friend class SDLSourceManager; - - void loadWAV(void* mem, int size); - void loadOGG(void* mem, int size); + void decode_wav(void* mem, int size); + void decode_ogg(void* mem, int size); inline bool is(int state) const { return (status.state & state) == state; } struct { const void* data; // 音频数据 - int size; // data字节长度 + int length; // data字节长度 const void* end; // data结尾 = (unsigned char*)data + size - int rate; // 采样频率 + int samplerate; // 采样频率 unsigned char bitdepth; // 每个sample的比特长度 int samples; // sample数 = size / (bitdepth / 8) - unsigned char channel; // channel数1(mono)或2(stereo) - char silence; // 0 + unsigned char channels; // channel数1(mono)或2(stereo) } raw; /* Procedure controller variable */ struct { - int pos; // 当前播放的位置 + int pos; // 当前播放的sample int pitch; // pitch int state; // 当前状态 bool loop; // loop or not @@ -85,10 +86,6 @@ namespace audio static void processCommands(); static void processSources(void* buffer, size_t size); - private: - - friend class SDLSource; - static void removeSource(SDLSource* source); static void pushSource(SDLSource* source); static SDLSourceCommand* getCommand(); -- cgit v1.1-26-g67d0