I'm having an issue with my application freezing on an al_set_audio_stream_playing(..., false) call. Here are some details about how my program works.
I am attaching several audio streams to the default mixer and setting them to playing simultaneously. When I try to stop them using al_set_audio_stream_playing(..., false), the first stream successfully stops. Subsequent streams will occasionally lock the program up on that call.
To start the streams, I do something like this:
I stop the streams in a similar manner:
After some debugging I found that the lock up was happening inside al_set_audio_stream_playing(). It is attempting to lock a mutex that is already locked by the stream feeder thread and it never gets the lock.
I found that the issue is caused by al_detach_audio_stream() setting the first stream's mutex to NULL after the stream feeder thread has locked the stream's mutex but before it unlocks it. This causes the first stream's mutex to never get unlocked. Since all of the streams are sharing a single mutex, the second stream will never get the mutex lock because it is still locked.