diff options
author | Charlie Birks <admin@daftgames.net> | 2014-01-28 12:03:40 +0000 |
---|---|---|
committer | Charlie Birks <admin@daftgames.net> | 2014-01-28 12:03:40 +0000 |
commit | 684d83d5df8fb26d35c10aebdd41f2368d36eff2 (patch) | |
tree | 4896dc06e6ab2d9e61d3b9e977ae2fa690c5ed8d /tests | |
parent | 96bd7bff27531061261f324d793ff22b79f157cd (diff) |
more tests and improvements to openal_playback.cpp to allow running native
Diffstat (limited to 'tests')
-rw-r--r-- | tests/openal_playback.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/openal_playback.cpp b/tests/openal_playback.cpp index ccaebbfc..6a8dae38 100644 --- a/tests/openal_playback.cpp +++ b/tests/openal_playback.cpp @@ -3,11 +3,15 @@ #include <AL/al.h> #include <AL/alc.h> #include <assert.h> +#include <stdint.h> +#include <unistd.h> +#ifdef EMSCRIPTEN #include <emscripten.h> +#endif void playSource(void* arg) { - ALuint source = reinterpret_cast<ALuint>(arg); + ALuint source = static_cast<ALuint>(reinterpret_cast<intptr_t>(arg)); ALint state; alGetSourcei(source, AL_SOURCE_STATE, &state); assert(state == AL_PLAYING); @@ -21,15 +25,32 @@ void playSource(void* arg) alGetSourcei(source, AL_SOURCE_STATE, &state); assert(state == AL_STOPPED); +#ifdef EMSCRIPTEN int result = 1; REPORT_RESULT(); +#endif } int main() { + int major, minor; + alcGetIntegerv(NULL, ALC_MAJOR_VERSION, 1, &major); + alcGetIntegerv(NULL, ALC_MAJOR_VERSION, 1, &minor); + + assert(major == 1); + + printf("ALC version: %i.%i\n", major, minor); + printf("Default device: %s\n", alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)); + ALCdevice* device = alcOpenDevice(NULL); ALCcontext* context = alcCreateContext(device, NULL); alcMakeContextCurrent(context); + assert(alGetString(AL_VERSION)); + + printf("OpenAL version: %s\n", alGetString(AL_VERSION)); + printf("OpenAL vendor: %s\n", alGetString(AL_VENDOR)); + printf("OpenAL renderer: %s\n", alGetString(AL_RENDERER)); + ALfloat listenerPos[] = {0.0, 0.0, 0.0}; ALfloat listenerVel[] = {0.0, 0.0, 0.0}; ALfloat listenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0}; @@ -42,7 +63,11 @@ int main() { alGenBuffers(1, buffers); +#ifdef EMSCRIPTEN FILE* source = fopen("audio.wav", "rb"); +#else + FILE* source = fopen("sounds/audio.wav", "rb"); +#endif fseek(source, 0, SEEK_END); int size = ftell(source); fseek(source, 0, SEEK_SET); @@ -121,7 +146,12 @@ int main() { alGetSourcei(sources[0], AL_SOURCE_STATE, &state); assert(state == AL_PLAYING); +#ifdef EMSCRIPTEN emscripten_async_call(playSource, reinterpret_cast<void*>(sources[0]), 700); +#else + usleep(700000); + playSource(reinterpret_cast<void*>(sources[0])); +#endif return 0; } |