Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sound in games, beginners question  (Read 3461 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Sound in games, beginners question
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sound in games, beginners question
« Reply #1 on: December 21, 2010, 07:31:39 am »
Quote
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.
Laurent Gomila - SFML developer