diff options
author | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
commit | 40fc27154fe754181934dc7ee31375e6bdfb33fc (patch) | |
tree | 897ad98d759bc308ef66561181ba88b85f2ccd47 /src/libjin/Audio/SDL/SDLSource.h | |
parent | 1480c9445100075c9e1a894eb07c0ef727b509a1 (diff) |
*merge from minimal
Diffstat (limited to 'src/libjin/Audio/SDL/SDLSource.h')
-rw-r--r-- | src/libjin/Audio/SDL/SDLSource.h | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/src/libjin/Audio/SDL/SDLSource.h b/src/libjin/Audio/SDL/SDLSource.h deleted file mode 100644 index dd792c7..0000000 --- a/src/libjin/Audio/SDL/SDLSource.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef __JIN_SOURCE_SDL_H -#define __JIN_SOURCE_SDL_H -#include "../../modules.h" -#if JIN_MODULES_AUDIO && JIN_AUDIO_SDLAUDIO - -#include <vector> -#include <queue> -#include <stack> -#include <exception> - -#include "../source.h" - -namespace jin -{ -namespace audio -{ - - typedef struct SDLSourceCommand; - class SDLSourceManager; - - class SDLSource : public Source - { - - public: - - ~SDLSource(); - - static SDLSource* createSource(const char* file); - static SDLSource* createSource(void* mem, size_t size); - - /* 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; - - inline void handle(SDLSourceManager* manager, SDLSourceCommand* cmd); - inline void process(void* buffer, size_t size); - - protected: - - SDLSource(); - - 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 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(); - - /* Process function */ - void processCommands(); - void processSources(void* buffer, size_t size); - - 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; - - }; - - class SourceException : public std::exception - { - const char * what() const throw () - { - return "Load Source Exception"; - } - }; - -} -} - -#endif // JIN_MODULES_AUDIO && JIN_AUDIO_SDLAUDIO -#endif // __JIN_SOURCE_SDL_H
\ No newline at end of file |