aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/openal_buffers.c54
-rwxr-xr-xtests/runner.py2
2 files changed, 35 insertions, 21 deletions
diff --git a/tests/openal_buffers.c b/tests/openal_buffers.c
index f89a5791..6f51a685 100644
--- a/tests/openal_buffers.c
+++ b/tests/openal_buffers.c
@@ -11,7 +11,7 @@
#endif
#define NUM_BUFFERS 4
-#define BUFFER_SIZE 1024*8
+#define BUFFER_SIZE 1470*10
ALCdevice* device = NULL;
ALCcontext* context = NULL;
@@ -26,22 +26,43 @@ unsigned int bits = 0;
ALenum format = 0;
ALuint source = 0;
-void cycle(void *arg) {
+void iter(void *arg) {
ALuint buffer = 0;
- ALint numBuffers = 0;
+ ALint buffersProcessed = 0;
+ ALint buffersWereQueued = 0;
+ ALint buffersQueued = 0;
+ ALint state;
- alGetSourcei(source, AL_BUFFERS_PROCESSED, &numBuffers);
+ alGetSourcei(source, AL_BUFFERS_PROCESSED, &buffersProcessed);
- while (offset < size && numBuffers--) {
+ while (offset < size && buffersProcessed--) {
+ // unqueue the old buffer and validate the queue length
+ alGetSourcei(source, AL_BUFFERS_QUEUED, &buffersWereQueued);
alSourceUnqueueBuffers(source, 1, &buffer);
+
+ assert(alGetError() == AL_NO_ERROR);
int len = size - offset;
if (len > BUFFER_SIZE) {
len = BUFFER_SIZE;
}
+
+ alGetSourcei(source, AL_BUFFERS_QUEUED, &buffersQueued);
+ assert(buffersQueued == buffersWereQueued - 1);
+
+ // queue the new buffer and validate the queue length
+ buffersWereQueued = buffersQueued;
alBufferData(buffer, format, &data[offset], len, frequency);
+
alSourceQueueBuffers(source, 1, &buffer);
assert(alGetError() == AL_NO_ERROR);
+ alGetSourcei(source, AL_BUFFERS_QUEUED, &buffersQueued);
+ assert(buffersQueued == buffersWereQueued + 1);
+
+ // make sure it's still playing
+ alGetSourcei(source, AL_SOURCE_STATE, &state);
+ assert(state == AL_PLAYING);
+
offset += len;
}
@@ -50,18 +71,8 @@ void cycle(void *arg) {
#ifdef EMSCRIPTEN
int result = 0;
REPORT_RESULT();
-#else
- exit(0);
-#endif
- }
- // Give the JS thread a few ms to breathe.
- else {
-#ifdef EMSCRIPTEN
- emscripten_async_call(cycle, NULL, 10);
-#else
- usleep(10);
- cycle();
#endif
+ exit(0);
}
}
@@ -165,9 +176,12 @@ int main(int argc, char* argv[]) {
//
// Cycle and refill the buffers until we're done.
//
-#ifdef EMSCRIPTEN
- emscripten_async_call(cycle, NULL, 10);
-#else
- cycle();
+#if EMSCRIPTEN
+ emscripten_set_main_loop(iter, 0, 0);
+#else
+ while (1) {
+ iter(NULL);
+ usleep(16);
+ }
#endif
}
diff --git a/tests/runner.py b/tests/runner.py
index 1781980a..2627d113 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -13252,7 +13252,7 @@ Press any key to continue.'''
shutil.copyfile(path_from_root('tests', 'sounds', 'the_entertainer.wav'), os.path.join(self.get_dir(), 'the_entertainer.wav'))
open(os.path.join(self.get_dir(), 'openal_buffers.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'openal_buffers.c')).read()))
- Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'openal_buffers.c'), '--preload-file', 'the_entertainer.wav', '-o', 'page.html']).communicate()
+ Popen([PYTHON, EMCC, '-O0', os.path.join(self.get_dir(), 'openal_buffers.c'), '--preload-file', 'the_entertainer.wav', '-o', 'page.html']).communicate()
self.run_browser('page.html', '', '/report_result?0')
def test_glfw(self):