Jump to content
  • Advertisement
Sign in to follow this  

Question about optimizing audio streams

This topic is 3716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have a question about how to optimze streaming in an audio lib. I have my own audio lib (build on DirectSound) and I have support for streaming sound/music (wav, ogg, mod, ym, etc). In my current implementation, each stream creates and manages it's own thread, used to push data in the audio double buffer, when needed. I was wondering if it's a better idea to have only one thread (except the main thread), created when the audio lib is initialized, and use it to check all playing streams. And if user wants to avoid threads, to have no thread at all, and call explicite some AudioUpdateStreams() (supposing the fps can handle it). I have some issues with creating and destroying threads, for example when the music changes during gameplay, and I want to optimize it. The playing stream has to be stopped and distroyed . Waiting for the thread to end, might create a small glitch on some computers (possibly because single processor). I tricked that, puting the stream in a 'garbage can' and delete it later, but the creation of an additional thread (the third one at that moment) might cause small delays in frame. I think I'll try and see how it goes with a single audio stream, but if anyone has experience with this practice, let me know. Thanks! Alex

Share this post


Link to post
Share on other sites
Advertisement
You should only have one thread manage all your streaming sound sources. If you create a thread for each sound source you will swamp the system with context switches (especially a single core system). Also, make sure you put some appropriate thread-wait procedure in place. I've found you can get a pretty big performance bump in a multi-core system by not just having threads sit around and spin.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!