This is a fix for bug #1189126:
http://sourceforge.net/tracker/index.php?func=detail&aid=1189126&group_id=63889&atid=505529
There is an opportunity for deadlock to occur in the
SDL sound code, causing random freezing. Here is an
example (sdlSoundLen starts off being < 4096):
--- audio thread (soundCallback)
if(!speedup && !throttle) {
while(sdlSoundLen < 2048*2) {
--- main thread (systemWriteDataToSoundBuffer)
sdlSoundLen = 2048*2;
SDL_CondSignal(cond);
--- audio thread
if(emulating)
SDL_CondWait(cond, mutex);
--- main thread
cont = true;
if(!speedup && !throttle) {
while(cont) {
SDL_mutexP(mutex);
if(sdlSoundLen < 2048*2)
cont = false;
SDL_mutexV(mutex);
}
At this point, the main thread has already signalled
the audio thread but the audio threadwas not listening.
So, the main thread waits for the buffer to be dumped,
constantly checking sdlSoundLen, while the audio thread
waits to be signalled.
My patch uses a cleaner implementation using semaphores
instead of conditional waiting. This also means that
VBA no longer uses 100% CPU due to busy waiting such as
the last loop in the example.
patch against current CVS
Logged In: YES
user_id=785003
Patch applied. Thanks !!!
Logged In: YES
user_id=1355343
There is still a freeze when closing the SDL window udner
windows. It freezes exactly when trying to execute
SDL_CloseAudio (); in function void systemSoundShutdown().
Unfortunately I do not understand what is going on there.