FAudio icon indicating copy to clipboard operation
FAudio copied to clipboard

Fix deadlock in voice callbacks

Open xtsm opened this issue 2 months ago • 3 comments

Second attempt. Previous here: https://github.com/FNA-XNA/FAudio/pull/337

Now that we release buffer lock before executing callbacks, some code from another thread can get scheduled between mutex unlock and callback call and observe empty buffer queue right before callback puts a new buffer there. XNA_Song determines the end of the song by simply checking if the queue is empty, which may lead to random playback breaks.

Not sure how to properly check for the song end but the buffer decoding function also zeroes out total samples counter when it finishes a EOS-flagged buffer so checking if that counter is zero should cut it... probably?

xtsm avatar Apr 21 '24 14:04 xtsm