thread-safety-analysis fails on AudioStreamOpenSLES.cpp
Oboe version: 1.9.2 (but still applies in 1.10.0)
Short description When building oboe with the WebRTC toolchain (a recent version such as m140), it fails since thread safety checks are enabled now by default.
Steps to reproduce
Add the -Wthread-safety compiler option and build.
Expected behavior
No compiler errors (since WebRTC is set to error out for this with -Werror,-Wthread-safety-analysis).
Actual behavior
src/opensles/AudioStreamOpenSLES.cpp:400:15: error: releasing mutex 'mLock' that was not held [-Werror,-Wthread-safety-analysis]
400 | mLock.unlock();
| ^
src/opensles/AudioStreamOpenSLES.cpp:405:5: error: mutex 'mLock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
405 | onAfterDestroy();
| ^
src/opensles/AudioStreamOpenSLES.cpp:402:15: note: mutex acquired here
402 | mLock.lock();
| ^
Any additional context
A workaround is to disable the check only for oboe with "-Wno-sign-compare", which is fine and the same as it was before. But it would be nice if the check worked. I am not sure if there is a specific annotation for this or just use NO_THREAD_SAFETY_ANALYSIS for the function.
Related to the fix provided here: https://github.com/google/oboe/issues/591
I would like to take this if it is still available.
Current main still documents close_l() as requiring mLock, but its declaration does not encode that precondition for Clang. Both input and output callers hold a lock_guard. I would investigate a small locking-contract fix that preserves the temporary unlock around OpenSL ES Destroy(), rather than disabling thread-safety analysis.
I plan to use AI assistance, validate with an Android NDK build using thread-safety warnings as errors, and personally review the resulting diff before requesting review. Please let me know if this approach is welcome or if there are project-specific AI contribution requirements beyond CONTRIBUTING.md.
No patch or successful Android build is claimed yet; I am preparing the build environment.