From 8b00d67febf133e89f6a0bfabc41feed555dc4a9 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 12 Jan 2019 21:48:33 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E6=8E=89=E6=96=87=E4=BB=B6=E5=89=8D=E7=BC=80?= =?UTF-8?q?je=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/audio/SDL/je_sdl_source.h | 265 ----------------------------------- 1 file changed, 265 deletions(-) delete mode 100644 src/libjin/audio/SDL/je_sdl_source.h (limited to 'src/libjin/audio/SDL/je_sdl_source.h') diff --git a/src/libjin/audio/SDL/je_sdl_source.h b/src/libjin/audio/SDL/je_sdl_source.h deleted file mode 100644 index 3f1c10f..0000000 --- a/src/libjin/audio/SDL/je_sdl_source.h +++ /dev/null @@ -1,265 +0,0 @@ -#ifndef __JE_SOURCE_SDL_H__ -#define __JE_SOURCE_SDL_H__ -#include "../../core/je_configuration.h" -#if defined(jin_audio) && (jin_audio == jin_audio_sdl) - -#include -#include -#include -#include - -#include "../je_source.h" - -namespace JinEngine -{ - namespace Audio - { - namespace SDL - { - - typedef struct SDLSourceCommand; - - class SDLSourceManager; - - /// - /// Audio source SDL implementation. - /// - class SDLSource : public Source - { - public: - /// - /// Source constructor. - /// - SDLSource(); - - /// - /// - /// - SDLSource(const char* file); - - /// - /// - /// - SDLSource(void* mem, size_t size); - - /// - /// Source destructor. - /// - ~SDLSource(); - - /// - /// Play source. - /// - void play() override; - - /// - /// Stop source. - /// - void stop() override; - - /// - /// Pause source. - /// - void pause() override; - - /// - /// Resume source. - /// - void resume() override; - - /// - /// Rewind source. - /// - void rewind() override; - - /// - /// Return if the source is stopped. - /// - /// @return True if the source is stopped, otherwise return false. - /// - bool isStopped() const override; - - /// - /// Return if the source is paused. - /// - /// @return True if the source is paused(, otherwise return false. - /// - bool isPaused() const override; - - /// - /// Set pitch. - /// - /// @param pitch Pitch of source. - /// - void setPitch(float pitch) override; - - /// - /// Set volume. - /// - /// @param volume Volume of source. - /// - void setVolume(float volume) override; - - /// - /// Set source loop. - /// - /// @param loop Looping or not. - /// - void setLoop(bool loop) override; - - /// - /// Set source rate. - /// - /// @param rate Rate of source. - /// - void setRate(float rate) override; - - /// - /// Handle a specific command. - /// - /// @param manager Audio manager. - /// @param cmd Source commad. - /// - inline void handle(SDLSourceManager* manager, SDLSourceCommand* cmd); - - /// - /// Process decoded source data. - /// - /// @param buffer Source data. - /// @param size Data size. - /// - inline void process(void* buffer, size_t size); - - protected: - /// - /// Decode wav file. - /// - /// @param mem Wav file data. - /// @param size Wav data size. - /// - void decode_wav(void* mem, int size); - - /// - /// Decode ogg file. - /// - /// @param mem ogg file data. - /// @param size ogg data size. - /// - void decode_ogg(void* mem, int size); - - /// - /// Check source state. - /// - /// @param state State to be checked. - /// @return True if state is given state, otherwise return false. - /// - inline bool is(int state) const - { - return (status.state & state) == state; - } - - // Source data. - 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; // channel数1(mono)或2(stereo) - } raw; - // Procedure controller variable. - struct { - int pos; // 当前播放的sample - int pitch; // pitch - int state; // 当前状态 - bool loop; // loop or not - float volume; // 音量 - } status; - - }; - - /// - /// Source manager. - /// - class SDLSourceManager : public Object - { - public: - /// - /// Get manager singleton. - /// - /// @return Singleton of SDL source manager. - /// - static SDLSourceManager* get(); - - /// - /// Process commands. - /// - void processCommands(); - - /// - /// Process sources. - /// - /// @param buffer Source data. - /// @param size Size of source data. - /// - void processSources(void* buffer, size_t size); - - /// - /// Clear source queue. - /// - /// This function will stop all sources. - /// - void removeAllSource(); - - /// - /// Remove specific source. - /// - /// @param source SDL audio source. - /// - void removeSource(SDLSource* source); - - /// - /// Push specific source into queue. - /// - /// @param source SDL audio source. - /// - void pushSource(SDLSource* source); - - /// - /// Get command from queue. - /// - /// @return Command at first place. - /// - SDLSourceCommand* getCommand(); - - /// - /// Push command. - /// - /// @param cmd Spcific command. - /// - void pushCommand(SDLSourceCommand* cmd); - - private: - std::queue commands; - std::stack commandsPool; - std::vector sources; // processing sources - static SDLSourceManager* manager; - - }; - - class SourceException : public Object, public std::exception - { - const char* what() const throw () - { - return "Load Source Exception"; - } - }; - - } // namespace SDL - } // namespace Audio -} // namespace JinEngine - -#endif // (jin_audio) && (jin_audio == jin_audio_sdl) - -#endif // __JE_SOURCE_SDL_H__ \ No newline at end of file -- cgit v1.1-26-g67d0