diff options
Diffstat (limited to 'src/libjin/Audio/SDL/SDLSource.h')
-rw-r--r-- | src/libjin/Audio/SDL/SDLSource.h | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/libjin/Audio/SDL/SDLSource.h b/src/libjin/Audio/SDL/SDLSource.h index c45d7e5..a99f65e 100644 --- a/src/libjin/Audio/SDL/SDLSource.h +++ b/src/libjin/Audio/SDL/SDLSource.h @@ -20,14 +20,11 @@ namespace audio class SDLSource : public Source { - public: - - ~SDLSource(); - static SDLSource* createSource(const char* file); static SDLSource* createSource(void* mem, size_t size); + ~SDLSource(); /* ISource interface */ void play() override; void stop() override; @@ -37,25 +34,22 @@ namespace audio bool isStopped() const override; bool isPaused() const override; void setPitch(float pitch) override; - // Ͻ void setVolume(float volume) override; bool setLoop(bool loop) override; void setRate(float rate) override; - + /* handle and process anduio clip */ inline void handle(SDLSourceManager* manager, SDLSourceCommand* cmd); inline void process(void* buffer, size_t size); protected: - SDLSource(); - + /* decode raw audio data */ void decode_wav(void* mem, int size); void decode_ogg(void* mem, int size); - + /* check state */ inline bool is(int state) const { return (status.state & state) == state; } - struct - { + struct{ const void* data; // Ƶ int length; // dataֽڳ const void* end; // dataβ = (unsigned char*)data + size @@ -64,10 +58,8 @@ namespace audio int samples; // sample = size / (bitdepth / 8) unsigned char channels; // channel1(mono)2(stereo) } raw; - /* Procedure controller variable */ - struct - { + struct{ int pos; // ǰŵsample int pitch; // pitch int state; // ǰ״̬ @@ -79,15 +71,13 @@ namespace audio class SDLSourceManager { - public: - static SDLSourceManager* get(); /* Process function */ void processCommands(); void processSources(void* buffer, size_t size); - + /* control flow */ void removeAllSource(); void removeSource(SDLSource* source); void pushSource(SDLSource* source); @@ -95,7 +85,6 @@ namespace audio void pushCommand(SDLSourceCommand* cmd); private : - std::queue<SDLSourceCommand*> commands; std::stack<SDLSourceCommand*> commandsPool; std::vector<SDLSource*> sources; // processing sources |