diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-27 12:14:09 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-27 12:14:09 -0700 |
commit | e39cb11407e0d646dca3cbea244ce4189680aa4a (patch) | |
tree | c161e998a74e3741d28473303a3631da09cc0394 /tests/sdl_audio.c | |
parent | d73a1a9680eb11ffbeeb7aa01af401af0af19d40 (diff) |
add audio test file
Diffstat (limited to 'tests/sdl_audio.c')
-rw-r--r-- | tests/sdl_audio.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/sdl_audio.c b/tests/sdl_audio.c new file mode 100644 index 00000000..2539b982 --- /dev/null +++ b/tests/sdl_audio.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <SDL/SDL.h> +#include <SDL/SDL_mixer.h> +#include <assert.h> +#include <emscripten.h> + +Mix_Chunk *sound; + +void play() { + int channel = Mix_PlayChannel(-1, sound, 1); + assert(channel >= 0); +} + +int main() { + SDL_Init(SDL_INIT_AUDIO); + + int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these.. + assert(ret == 0); + + sound = Mix_LoadWAV("sound.ogg"); + assert(sound); + + play(); + + emscripten_run_script("element = document.createElement('input');" + "element.setAttribute('type', 'button');" + "element.setAttribute('value', 'replay!');" + "element.setAttribute('onclick', '_play()');" + "document.body.appendChild(element);"); + + printf("you should hear a victory sound. press the button to replay!\n"); + + int result = 1; + REPORT_RESULT(); + + return 0; +} + |