Open davidmanzanares opened 4 years ago
Hi, thanks for reporting this! Are you making the calls concurrently? If you are calling Mixed.Add
multiple times concurrently, that will cause a race condition. In general, no Beep object (except for the speaker) is concurrency-safe and if you're using it concurrently, you'll have to guard it with mutexes or something.
Oh, I just realized what probably is the issue. You're modifying a streamer that's currently playing, right? That will cause a race condition because the speaker will pull data from the streamer at the same time as you are modifying it.
To prevent this, use speaker.Lock(), that will prevent the speaker from pulling data, modify your streamer and then call speaker.Unlock() to let the speaker pull data again.
Hi,
After some unexpected crashes that pointed to an issue with Go's GC (I assume something is wrong in my code or on one of my dependencies), I ran my program with
-race
and found the data race I left at the end.After seeing this, I think there is a race condition between an internal beep go-routine and the one I have making calls like these:
Is this expected / do I have to call something to manage proper sync? Is this a bug?
Thank you very much :)
Initialization code that may be useful: