[SDL] Problem with mp3 playback using SDL_mixer and SMPeg.dll

Ryan C. Gordon icculus at icculus.org
Thu Jan 4 15:47:39 PST 2007


> However he does worry when folks assert that killing a thread
> is safer than convincing it to exit of natural causes. Poor fellow
> had a difficult childhood - they used to whip him with threads.

Child abuse aside, forcefully killing a thread is a bad idea. It's not 
portable, it's inelegant, and it leaves many systems in undefined 
states. If you have to kill a thread, your program is probably trying to 
recover from a deadlock bug. Better to just crash at this point and fix 
the bug.   :)

Also, SDL_KillThread() will be a no-op in 1.3:
    http://bugzilla.libsdl.org/show_bug.cgi?id=205

> Can I use the SDL thread synchronisation functions in the sound callback?
> Or is the sound callback not always a thread?

It's not always a thread (it's a hardware interrupt on Mac OS 9 and 
other legacy/embedded systems), or it might not be a thread we 
explicitly created (depending on the backend API). This is why there is 
an SDL_LockAudio() call that is separate from the regular thread 
primitives, and it works even on systems that don't offer threads like 
Mac OS 9.

You can assume you already hold the SDL_LockAudio() lock when your 
callback starts running, and your callback won't run while something 
else holds the lock.

--ryan.





More information about the SDL mailing list