SFML community forums
Help => Audio => Topic started by: ravenheart on December 21, 2010, 12:07:24 am
-
Well i havent found an answer to this .
If i have a look at the sound tutorial eg, i see the sleep() method.
Why is it there exactly?
(it says leave some time for other threads)
would playing the sound without sleep take over the whole cpu and nothing else could be done (similiar to fractals?)
should sound be handled in an extra thread when programming a game?
-
should sound be handled in an extra thread when programming a game?
They are. That's why there's no need to block the main thread at 100% CPU -- in the example, it does nothing while the sound is playing. But of course in a real application, the main thread will most likely be busy doing something else, and won't wait for the sound to finish with a sleep loop.