Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/libopenal.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,9 @@ var LibraryOpenAL = {
AL.setSourceState(src, {{{ cDefs.AL_INITIAL }}});
}

if (src.bufQueue[src.bufsProcessed].audioBuf !== null) {
src.bufsProcessed = 0;
while (offset > src.bufQueue[src.bufsProcessed].audioBuf.duration) {
src.bufsProcessed = 0;
if (src.bufQueue.length && src.bufQueue[0].audioBuf) {
while (src.bufsProcessed < src.bufQueue.length && offset > src.bufQueue[src.bufsProcessed].audioBuf.duration) {
offset -= src.bufQueue[src.bufsProcessed].audioBuf.duration;
src.bufsProcessed++;
}
Expand Down
12 changes: 11 additions & 1 deletion test/openal/test_openal_playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ void playSource(void* arg) {
alSourceStop(source);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
#ifdef TEST_STOPPED_SEEK
alSourcef(source, AL_SEC_OFFSET, 0.5f);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
#endif
#endif

alSourceRewindv(1, &source);
Expand All @@ -69,6 +74,11 @@ void playSource(void* arg) {
alSourceStopv(1, &source);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
#ifdef TEST_STOPPED_SEEK
alSourcef(source, AL_SEC_OFFSET, 0.5f);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
Comment thread
uniformization marked this conversation as resolved.
#endif
test_finished();
#endif
}
Expand Down Expand Up @@ -293,7 +303,7 @@ int main() {
printf("You should hear a short audio clip playing back.\n");
#endif

#ifdef __EMSCRIPTEN__
#if defined(__EMSCRIPTEN__) && !defined(TEST_STOPPED_SEEK)

intptr_t first_src = sources[0];
#if defined(TEST_LOOPED_PLAYBACK)
Expand Down
4 changes: 4 additions & 0 deletions test/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def test_openal_playback(self, args):
copy_asset('sounds/audio.wav')
self.btest('openal/test_openal_playback.c', '1', cflags=['-O2', '--preload-file', 'audio.wav'] + args)

def test_openal_stopped_seek_playback(self):
copy_asset('sounds/audio.wav')
self.btest('openal/test_openal_playback.c', '1', cflags=['-DTEST_STOPPED_SEEK=1', '-O2', '--preload-file', 'audio.wav'])

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

Expand Down