diff options
Diffstat (limited to 'src/libjin/Audio/SDL/SDLSource.h')
-rw-r--r-- | src/libjin/Audio/SDL/SDLSource.h | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/src/libjin/Audio/SDL/SDLSource.h b/src/libjin/Audio/SDL/SDLSource.h index 3feef9f..d9059cb 100644 --- a/src/libjin/Audio/SDL/SDLSource.h +++ b/src/libjin/Audio/SDL/SDLSource.h @@ -12,95 +12,95 @@ namespace jin { -namespace audio -{ + namespace audio + { - typedef struct SDLSourceCommand; - class SDLSourceManager; + typedef struct SDLSourceCommand; + class SDLSourceManager; - class SDLSource : public Source - { - public: - static SDLSource* createSource(const char* file); - static SDLSource* createSource(void* mem, size_t size); + class SDLSource : public Source + { + public: + static SDLSource* createSource(const char* file); + static SDLSource* createSource(void* mem, size_t size); - ~SDLSource(); - /* ISource interface */ - void play() override; - void stop() override; - void pause() override; - void resume() override; - void rewind() override; - 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); + ~SDLSource(); + /* ISource interface */ + void play() override; + void stop() override; + void pause() override; + void resume() override; + void rewind() override; + 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; } + 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{ - const void* data; // Ƶ - int length; // dataֽڳ - const void* end; // dataβ = (unsigned char*)data + size - int samplerate; // Ƶ - unsigned char bitdepth; // ÿsampleıس - int samples; // sample = size / (bitdepth / 8) - unsigned char channels; // channel1(mono)2(stereo) - } raw; - /* Procedure controller variable */ - struct{ - int pos; // ǰŵsample - int pitch; // pitch - int state; // ǰ״̬ - bool loop; // loop or not - float volume; // - } status; + struct{ + const void* data; // Ƶ + int length; // dataֽڳ + const void* end; // dataβ = (unsigned char*)data + size + int samplerate; // Ƶ + unsigned char bitdepth; // ÿsampleıس + int samples; // sample = size / (bitdepth / 8) + unsigned char channels; // channel1(mono)2(stereo) + } raw; + /* Procedure controller variable */ + struct{ + int pos; // ǰŵsample + int pitch; // pitch + int state; // ǰ״̬ + bool loop; // loop or not + float volume; // + } status; - }; + }; - class SDLSourceManager - { - public: - static SDLSourceManager* get(); + 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); - SDLSourceCommand* getCommand(); - void pushCommand(SDLSourceCommand* cmd); + /* Process function */ + void processCommands(); + void processSources(void* buffer, size_t size); + /* control flow */ + void removeAllSource(); + void removeSource(SDLSource* source); + void pushSource(SDLSource* source); + SDLSourceCommand* getCommand(); + void pushCommand(SDLSourceCommand* cmd); - private : - std::queue<SDLSourceCommand*> commands; - std::stack<SDLSourceCommand*> commandsPool; - std::vector<SDLSource*> sources; // processing sources - static SDLSourceManager* manager; + private : + std::queue<SDLSourceCommand*> commands; + std::stack<SDLSourceCommand*> commandsPool; + std::vector<SDLSource*> sources; // processing sources + static SDLSourceManager* manager; - }; + }; - class SourceException : public std::exception - { - const char * what() const throw () - { - return "Load Source Exception"; - } - }; + class SourceException : public std::exception + { + const char * what() const throw () + { + return "Load Source Exception"; + } + }; -} // audio + } // audio } // jin #endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO |