Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions src/lib/libopenal.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,13 +724,17 @@ 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 > 0 && src.bufQueue[0].audioBuf !== null) {
Comment thread
uniformization marked this conversation as resolved.
Outdated
while (src.bufsProcessed < src.bufQueue.length && offset > src.bufQueue[src.bufsProcessed].audioBuf.duration) {
offset -= src.bufQueue[src.bufsProcessed].audioBuf.duration;
src.bufsProcessed++;
}

if (src.bufsProcessed >= src.bufQueue.length) {
Comment thread
uniformization marked this conversation as resolved.
Outdated
src.bufsProcessed = src.bufQueue.length -1;
Comment thread
uniformization marked this conversation as resolved.
Outdated
}

src.bufOffset = offset;
}

Expand Down
6 changes: 6 additions & 0 deletions test/openal/test_openal_playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void playSource(void* arg) {
alSourceStop(source);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
alSourcef(source, AL_SEC_OFFSET, 0.5f);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
#endif

alSourceRewindv(1, &source);
Expand All @@ -69,6 +72,9 @@ void playSource(void* arg) {
alSourceStopv(1, &source);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
alSourcef(source, AL_SEC_OFFSET, 0.5f);
alGetSourcei(source, AL_SOURCE_STATE, &state);
assert(state == AL_STOPPED);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm this new test fails without this patch?

Copy link
Copy Markdown
Author

@uniformization uniformization Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if the fix for this is good enough or if there's a better way of going about it. When an error is thrown from a function that was called with emscripten_async_call, it won't fail the test. (Line 306)

test_finished();
#endif
}
Expand Down