[OpenAL] Fix sourceSeek crash on stopped sources - #26770
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Could you maybe modify one of the existing tests in test_browser.py or test_inerative.py to cover this?
@sbc100 I have added a test to |
|
@sbc100 The issues have been resolved, let me know if the fix for the failing/passing the test is good |
| #endif | ||
| #else | ||
| usleep(700000); | ||
| playSource((void*)(sources[0])); |
There was a problem hiding this comment.
So in this mode you are calling playSource directly from the main function. Is it important for this test that you don't go via emscripten_async_call (like the !TEST_LOOPED_PLAYBACK case above?)
There was a problem hiding this comment.
@sbc100 Yes, if unpatched, it will error, but the test will not fail if I call it through emscripten_async_call.
|
I did some research and came up with a slightly different fix/test: #27426. I'm happy to credit you as a co-author on that PR. What do you think of my alternative change? |
Fix a crash in `sourceSeek` when called on a stopped source by resetting `bufsProcessed = 0` before evaluating buffer durations. This replaces emscripten-core#26770. Unlike emscripten-core#26770, which added a top-level check on `src.bufQueue[0]`, this change handles zero/dummy buffers and empty queues safely anywhere in `bufQueue` via `for .. of` iteration and `audioBuf?.duration ?? 0.0`. It also adds assertions to `test_openal_error.c` to verify state correctness after seeking. See: emscripten-core#26770
Fix a crash in `sourceSeek` when called on a stopped source by resetting `bufsProcessed = 0` before evaluating buffer durations. This replaces emscripten-core#26770. Unlike emscripten-core#26770, which added a top-level check on `src.bufQueue[0]`, this change handles zero/dummy buffers and empty queues safely anywhere in `bufQueue` via `for .. of` iteration and `audioBuf?.duration ?? 0.0`. It also adds assertions to `test_openal_error.c` to verify state correctness after seeking. See: emscripten-core#26770
Fix a crash in `sourceSeek` when called on a stopped source by resetting `bufsProcessed = 0` before evaluating buffer durations. This replaces emscripten-core#26770. Unlike emscripten-core#26770, which added a top-level check on `src.bufQueue[0]`, this change handles zero/dummy buffers and empty queues safely anywhere in `bufQueue` via `for .. of` iteration and `audioBuf?.duration ?? 0.0`. It also adds assertions to `test_openal_error.c` to verify state correctness after seeking. See: emscripten-core#26770
Fix a crash in `sourceSeek` when called on a stopped source by resetting `bufsProcessed = 0` before evaluating buffer durations. This replaces emscripten-core#26770. Unlike emscripten-core#26770, which added a top-level check on `src.bufQueue[0]`, this change handles zero/dummy buffers and empty queues safely anywhere in `bufQueue` via `for .. of` iteration and `audioBuf?.duration ?? 0.0`. It also adds assertions to `test_openal_error.c` to verify state correctness after seeking. See: emscripten-core#26770
Fix a crash in `sourceSeek` when called on a stopped source by resetting `bufsProcessed = 0` before evaluating buffer durations. This replaces #26770. Unlike #26770, which added a top-level check on `src.bufQueue[0]`, this change handles zero/dummy buffers and empty queues safely anywhere in `bufQueue` via `for .. of` iteration and `audioBuf?.duration ?? 0.0`. It also adds assertions to `test_openal_error.c` to verify state correctness after seeking. See: #26770
If you tried to use
AL_SEC_OFFSETon a stopped audio source, sourceSeek would throw aTypeErrorbecauseaudioBufwould be undefined.