aboutsummaryrefslogtreecommitdiff
path: root/test/load ogg.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-21 00:09:36 +0800
committerchai <chaifix@163.com>2018-12-21 00:09:36 +0800
commita567e2277d241be6a03bc5f0f6b3ba71b0efa536 (patch)
tree2d693e11c98796b9b71c83e09118dfec4e194584 /test/load ogg.cpp
parentcef467cefd2dfcb82b5973542b6d49e96931700b (diff)
-test
Diffstat (limited to 'test/load ogg.cpp')
-rw-r--r--test/load ogg.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/test/load ogg.cpp b/test/load ogg.cpp
deleted file mode 100644
index afa5b60..0000000
--- a/test/load ogg.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "utils.h"
-#if UNITTEST
-
-#include <iostream>
-#include <stdio.h>
-#include <fstream>
-#include "../audio/sdl/source.h"
-#include "../audio/sdl/audio.h"
-
-using namespace jin::audio;
-using namespace std;
-
-struct OGG
-{
- int samples;
- int channel, samplerate;
- short* data;
- int pos;
-};
-
-OGG ogg;
-
-static void callbackfunc(void *userdata, Uint8 *stream, int len)
-{
- int16_t* buffer = (int16_t*)stream;
- int16_t* oggbuf = (int16_t*)ogg.data;
- oggbuf += ogg.pos;
- for (int i = 0; i < len / 2; ++i)
- {
- buffer[i] = oggbuf[i];
- }
- ogg.pos += len / 2;
-}
-
-int main(int argc, char* argv[])
-{
- Audio* audio = SDLAudio::get();
- ifstream fs;
- fs.open("a.ogg", ios::binary);
- fs.seekg(0, ios::end);
- int size = fs.tellg();
- fs.seekg(0, ios::beg);
- char* buffer = new char[size];
- memset(buffer, 0, size);
- fs.read(buffer, size);
- ogg.samples = stb_vorbis_decode_memory((unsigned char*)buffer, size, &ogg.channel, &ogg.samplerate, &ogg.data);
- ogg.pos = 0;
- SDLAudioSetting setting;
- SDL_AudioSpec spe;
- setting.callback = callbackfunc;
- audio->init(&setting);
- while (true)
- {
- SDL_Delay(100);
- }
- audio->quit();
- return 0;
-}
-
-#endif \ No newline at end of file