So I found if the sound sync option is turned off the crashes stop. I also found that the real culprit was the way the audio was written, using LWP threads and mutexes. So I've rewritten the audio code to not use the threads or mutexes. It seems to be behaving pretty well and turbo mode works again and sound sync can be turned on.
So:
- no more audio blips
- no more crashes
- dynamic rate control seems to be keeping the number of unplayed samples to sensible amounts
- turbo mode works
The only thing that isn't solved is a big one: if the buffer being filled happens to be the same buffer being played, the audio becomes terrible. This generally doesn't happen but if it does, you either have to wait a minute for the two to stop colliding, or going back to the menu for a second or using the turbo stick will fix it. You can also force this collision to happen by using the turbo stick and if you're "unlucky" enough you'll have synced up the read buffer number with the write buffer number...which is what we want to avoid.
I'm not sure how best to solve this programatically. Basically it's a variant of a ringbuffer. It would be nice if there were other developers who could take a look and either code a fix or suggest a fix.
Anyway here's the beta for anyone interested.
… and a quick and dirty attempt to prevent the buffer collisions. I think this is the best you're going to get from me.
Hi!
I have tested the version "snes9xgx-sound-anti-collision" and the results are as follows:
The positive:
- I played 1 hour of "zelda alttp" and the sound is perfect, no distortion and also the console was not locked.
- I tried the turbo mode several times and everything normal.
- Heavy games like yoshi island have the same performance as before.
- When you enter the "chrono trigger" and "super mario rpg" menu everything is heard correctly.
- I tried a MSU-1 game quickly and everything seems to work correctly, I forgot to try the save function however.
The only negative:
- Graphic distortions in "top gear 3000" are still found.
Some suggestions for perfection:
- The subject of the image filter, will there be any way that the pixels with the filtered image are more noticeable?
Maybe the "defliker" theme ...
- Is it possible that there is a 240p video mode with the filtered image? as it happens in vbagx
I really appreciate your work, I noticed a lot of effort in the changes of the emulator, thank you very much!