aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/audio/sdl/audio.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-05-21 16:02:00 +0800
committerchai <chaifix@163.com>2018-05-21 16:02:00 +0800
commitfa234f9663b992cf50bcf865a1cde6845b42193c (patch)
tree34ecd41b60ef48c960a79a4077e5e0c8536102fd /src/libjin/audio/sdl/audio.cpp
parent51ba9cb2a6b0b9395a2912eadeb954c95e4c1d3c (diff)
修改audio模块
Diffstat (limited to 'src/libjin/audio/sdl/audio.cpp')
-rw-r--r--src/libjin/audio/sdl/audio.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/libjin/audio/sdl/audio.cpp b/src/libjin/audio/sdl/audio.cpp
new file mode 100644
index 0000000..0559c18
--- /dev/null
+++ b/src/libjin/audio/sdl/audio.cpp
@@ -0,0 +1,83 @@
+#include "audio.h"
+
+namespace jin
+{
+namespace audio
+{
+
+ onlyonce bool SDLAudio::_init(const SettingBase* s)
+ {
+ if (SDL_Init(SDL_INIT_AUDIO) < 0)
+ return false;
+
+ const SDLAudioSetting* setting = (SDLAudioSetting*)s;
+ SDL_AudioSpec wanted;
+ zero(wanted);
+ wanted.freq = setting->rate;
+ wanted.format = setting->resolution;
+ wanted.channels = setting->channels;
+ wanted.samples = setting->samples;
+ wanted.userdata = setting->userdata;
+ wanted.callback = setting->callback;
+
+ if (SDL_OpenAudio(&wanted, NULL) < 0)
+ {
+ return false;
+ }
+ // start audio
+ SDL_PauseAudio(0);
+ return true;
+ }
+
+ onlyonce void SDLAudio::_quit()
+ {
+ SDL_CloseAudio();
+ delete audio;
+ }
+
+ void SDLAudio::defaultCallback(void *udata, Uint8 *stream, int len)
+ {
+
+ }
+
+ void SDLAudio::play() {}
+
+ void SDLAudio::stop() {}
+
+ bool SDLAudio::pause()
+ {
+ return false;
+ }
+
+ bool SDLAudio::pause(Source* source)
+ {
+ return false;
+ }
+
+ bool SDLAudio::resume()
+ {
+ return false;
+ }
+
+ bool SDLAudio::resume(Source* source)
+ {
+ return false;
+ }
+
+ void SDLAudio::rewind()
+ {
+
+ }
+
+ void SDLAudio::setVolume(float volume)
+ {
+
+ }
+
+ float SDLAudio::getVolume()
+ {
+ return 0.f;
+ }
+
+}
+}