[SDL] SDL audiospec thread priority should be higher than the main
Nathaniel J Fries
nfries88 at yahoo.com
Wed Apr 20 11:01:37 PDT 2011
I am seeing things in this thread that I must disagree with.
1) Don't call SDL_Delay in the main loop? No, you should be sleeping in the main loop. Otherwise, your thread is (almost) always running for its full quantum, which is bad. You'll also notice that sleeping for that 1ms in the main loop decreases CPU usage of your program significantly, which means that you're using less power. This is especially important on an embedded system like an iOS or Android device, but it's still important on a desktop system too. Greener is better.
Also, the symptom you're receiving isn't from SDL's audiospec loop being too slow relative to the main thread. It's the two threads competing with eachother for processor time, and the main loop happens to be winning out (the audiospec loop probably sleeps or waits on some OS-provided synchronization primitive at some point, whereas the main thread does not).
2) If you have >30fps, you're "okay". Visual stutter may occur occasionally, but generally frames will blur together just fine for the human eye. If you're >60 frames, you're "perfect". There is no way to make it any better quality than 60fps. Ever hear of vsync? It exists for a reason. Trying to max out your framerate at >200fps is completely frivolous, as aside for that nice little number that you may optionally show to your end-user, the end-user wouldn't notice the difference between 60 and 6million. Take the 20fps hit if it fixes your problem.
Well, that's it for now. Enjoy.
EM3 Nathaniel Fries, U.S. Navy
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL