Skip to content

Commit da0ae80

Browse files
authored
Fix iteration of OpenAL src.bufQueue (#23916)
This failing test shows up under the interactive tests only, so I guess CI didn't catch it. Caused by #23867 .
1 parent e752352 commit da0ae80

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

src/lib/libopenal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4056,7 +4056,7 @@ var LibraryOpenAL = {
40564056
40574057
// Find the first non-zero buffer in the queue to determine the proper format
40584058
var templateBuf = AL.buffers[0];
4059-
for (var buf of src.bufQueue.length) {
4059+
for (var buf of src.bufQueue) {
40604060
if (buf.id !== 0) {
40614061
templateBuf = buf;
40624062
break;

test/openal/test_openal_buffers.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ void iter() {
8989
alGetSourcef(source, AL_PITCH, &testPitch);
9090
assert(pitch == testPitch);
9191
#endif
92-
92+
#ifndef TEST_INTERACTIVE
93+
offset = size;
94+
#endif
9395
// Exit once we've processed the entire clip.
9496
if (offset >= size) {
9597
#if __EMSCRIPTEN__
@@ -192,7 +194,6 @@ int main(int argc, char* argv[]) {
192194
ALint srcLen = 0;
193195
alGetSourcei(source, 0x2009 /* AL_BYTE_LENGTH_SOFT */, &srcLen);
194196
assert(srcLen == NUM_BUFFERS * BUFFER_SIZE);
195-
196197
#ifdef TEST_ANIMATED_PITCH
197198
printf("You should hear a clip of the 1902 piano song \"The Entertainer\" played back at a high pitch rate, and animated to slow down to half playback speed.\n");
198199
#else

test/openal/test_openal_playback.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,11 @@ int main() {
295295

296296
#ifdef __EMSCRIPTEN__
297297

298+
intptr_t first_src = sources[0];
298299
#if defined(TEST_LOOPED_PLAYBACK)
299-
emscripten_set_main_loop_arg(main_tick, (void*)sources[0], 0, 0);
300+
emscripten_set_main_loop_arg(main_tick, (void*)first_src, 0, 0);
300301
#else
301-
emscripten_async_call(playSource, (void*)(sources[0]), 700);
302+
emscripten_async_call(playSource, (void*)first_src, 700);
302303
#endif
303304
#else
304305
usleep(700000);

test/test_browser.py

+7
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,13 @@ def test_openal_capture_sanity(self):
23232323
def test_openal_extensions(self):
23242324
self.btest_exit('openal/test_openal_extensions.c')
23252325

2326+
def test_openal_playback(self):
2327+
shutil.copy(test_file('sounds/audio.wav'), '.')
2328+
self.btest_exit('openal/test_openal_playback.c', emcc_args=['-O2', '--preload-file', 'audio.wav'],)
2329+
2330+
def test_openal_buffers(self):
2331+
self.btest_exit('openal/test_openal_buffers.c', emcc_args=['--preload-file', test_file('sounds/the_entertainer.wav') + '@/'],)
2332+
23262333
def test_runtimelink(self):
23272334
create_file('header.h', r'''
23282335
struct point {

test/test_interactive.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ def test_openal_playback(self, args):
159159
self.btest('openal/test_openal_playback.c', '1', emcc_args=['-O2', '--preload-file', 'audio.wav'] + args)
160160

161161
def test_openal_buffers(self):
162-
self.btest_exit('openal/test_openal_buffers.c', emcc_args=['--preload-file', test_file('sounds/the_entertainer.wav') + '@/'],)
162+
self.btest_exit('openal/test_openal_buffers.c', emcc_args=['-DTEST_INTERACTIVE=1', '--preload-file', test_file('sounds/the_entertainer.wav') + '@/'],)
163163

164164
def test_openal_buffers_animated_pitch(self):
165-
self.btest_exit('openal/test_openal_buffers.c', emcc_args=['-DTEST_ANIMATED_PITCH=1', '--preload-file', test_file('sounds/the_entertainer.wav') + '@/'],)
165+
self.btest_exit('openal/test_openal_buffers.c', emcc_args=['-DTEST_INTERACTIVE=1', '-DTEST_ANIMATED_PITCH=1', '--preload-file', test_file('sounds/the_entertainer.wav') + '@/'],)
166166

167167
def test_openal_looped_pitched_playback(self):
168168
self.btest('openal/test_openal_playback.c', '1', emcc_args=['-DTEST_LOOPED_PLAYBACK=1', '--preload-file', test_file('sounds/the_entertainer.wav') + '@/audio.wav'],)

0 commit comments

Comments
 (0)