Jump to content
  • Advertisement
Sign in to follow this  
ProblemBaby

DirectSound, Streaming Buffers

This topic is 4848 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

Hi Ive problems to set up my streaming buffers with DirectSound. The documentation is quite bad, I dont understand how the Event thing works. Plz point me ouy to a good tutorial or if its easy tell me what Ive to do. thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
It's not too complicated. You should create sound buffer with sufficient length. For examle one second or fewer. Buffer must be created with flag DSBCAPS_CTRLPOSITIONNOTIFY. Than slice this buffer into small pieces. I use only two halves, it's enough. Set notification events on each pieces, i.e. in our example in the middle of buffer and at the end of buffer.

LPDIRECTSOUNDNOTIFY8 lpDsNotify;
pSoundBuffer->QueryInterface (IID_IDirectSoundNotify8, (LPVOID*)&lpDsNotify)

DSBPOSITIONNOTIFY PositionNotify[2];
// PositionNotify - setting offsets and events ...
// events create with CreateEvent()
// do not use DSBPN_OFFSETSTOP as the end offset
lpDsNotify->SetNotificationPositions (2, (LPCDSBPOSITIONNOTIFY)&PositionNotify)
lpDsNotify->Release()

That's it. Play buffer with DSBPLAY_LOOPING flag. Test the events with WaitForSingleObject() or WaitForMultipleObjects() in same or another thread, it's up to you. When the event become signaled update related piece of buffer. And one advise. Create stream buffers in software (DSBCAPS_LOCSOFTWARE), onterwise the events may fire also on stopped buffers.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!