openframeworks / openframeworks/openFrameworks
ofOpenALSoundPlayer uses a thread internally does not appear thread-safe
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
ofOpenALSoundPlayer looks like it ought to have locks around all of its functions. it's using a threadedFunction to handle updating/processing the sound playback streams in a background thread.
although OpenAL is itself thread-safe, our code is not thread safe. for example unloadSound deletes channels and sources but if it does this while threadedFunction() is running so a channel might become invalid halfway through updating it on our side, leading to for example a bad buffer reference being passed to different functions.
also, handling of stream_end is broken. if in the main thread stream_end is assigned true while the threadedFunction is executing code between https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp#L505 and line 520, when line 521 executes the value of stream_end is assigned back to false and the stream will not end.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp, especially threadedFunction() and the code around lines 505–521, then inspect unloadSound and related playback functions. Reproduce or reason through concurrent stream updates and unloading; done means shared state remains consistent and stream_end is not incorrectly cleared during background processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100