diff options
author | Michael Bishop <mbtyke@gmail.com> | 2013-06-13 12:46:44 -0400 |
---|---|---|
committer | Michael Bishop <mbtyke@gmail.com> | 2013-06-13 12:46:44 -0400 |
commit | 5b41371bb5897a49e1fdcad18d053f775105c846 (patch) | |
tree | 0de6cc2e4c62025dca1f555bd8a17b52fa90a4bb | |
parent | 886e3158cf5d95a2c2721e5eb9a1c3ac4461f805 (diff) |
Added test for SDL_Mix that includes looping audio.
The test demonstrates that looping produces gaps in the sound.
-rwxr-xr-x | tests/runner.py | 3 | ||||
-rw-r--r-- | tests/sdl_audio_mix.c | 12 | ||||
-rw-r--r-- | tests/sounds/noise.ogg | bin | 0 -> 9205 bytes |
3 files changed, 13 insertions, 2 deletions
diff --git a/tests/runner.py b/tests/runner.py index 5e101024..d6ac8a5d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -12279,9 +12279,10 @@ elif 'browser' in str(sys.argv): def test_sdl_audio_mix(self): shutil.copyfile(path_from_root('tests', 'sounds', 'pluck.ogg'), os.path.join(self.get_dir(), 'sound.ogg')) shutil.copyfile(path_from_root('tests', 'sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'music.ogg')) + shutil.copyfile(path_from_root('tests', 'sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'noise.ogg')) open(os.path.join(self.get_dir(), 'sdl_audio_mix.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_mix.c')).read())) - Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '-o', 'page.html']).communicate() + Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '--preload-file', 'noise.ogg', '-o', 'page.html']).communicate() self.run_browser('page.html', '', '/report_result?1') def test_sdl_audio_quickload(self): diff --git a/tests/sdl_audio_mix.c b/tests/sdl_audio_mix.c index f72f9c43..a1c0485d 100644 --- a/tests/sdl_audio_mix.c +++ b/tests/sdl_audio_mix.c @@ -5,9 +5,11 @@ #include <emscripten.h> static Mix_Chunk *sound = NULL; +static Mix_Chunk *noiseLoop = NULL; static Mix_Music *music = NULL; static int soundChannel = 0; +static int noiseLoopChannel = 0; void one_iter(); void one_iter() { @@ -19,6 +21,12 @@ void one_iter() { soundChannel = Mix_PlayChannel(-1, sound, 0); printf("channel = %d", soundChannel); assert(soundChannel != -1 && soundChannel != 0); + + noiseLoopChannel = Mix_PlayChannel(-1, noiseLoop, -1); + printf("noiseLoopChannel = %d", noiseLoopChannel); + assert(noiseLoopChannel != -1 && noiseLoopChannel != 0); + // set noiseLoopChannel to half volume + Mix_Volume(noiseLoopChannel,MIX_MAX_VOLUME/10); break; case 2: printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel)); @@ -70,9 +78,11 @@ int main(int argc, char **argv) { sound = Mix_LoadWAV("sound.ogg"); assert(sound); + noiseLoop = Mix_LoadWAV("noise.ogg"); + assert(noiseLoop); + music = Mix_LoadMUS("music.ogg"); assert(music); - emscripten_set_main_loop(one_iter, 30, 0); // force a quit diff --git a/tests/sounds/noise.ogg b/tests/sounds/noise.ogg Binary files differnew file mode 100644 index 00000000..c53d49a7 --- /dev/null +++ b/tests/sounds/noise.ogg |