Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bahe

problem with directsound buffer event notifications

This topic is 5481 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, Why a direct sound buffer may send position notifications events although it is not playing? I have this problem and could not solve it, it just works fine on win98 but on some systems with winXP the problem appears (some winXP systems work fine). here is what i (normally) do: //create direct sound Buffer WAVEFORMATEX wfx; memset(&wfx, 0, sizeof(WAVEFORMATEX)); wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.nChannels = vi.channels; wfx.nSamplesPerSec = vi.rate; wfx.wBitsPerSample = 16; wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels; wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; DSBUFFERDESC dsbdesc; ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwFlags =DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME;// | DSBCAPS_CTRLALL ; dsbdesc.dwBufferBytes = soundBufferSize; dsbdesc.lpwfxFormat = &wfx; if(lpds->CreateSoundBuffer(&dsbdesc, &lpdsb, NULL)!=DS_OK) { //error code } LPDIRECTSOUNDNOTIFY lpDsNotify; DSBPOSITIONNOTIFY PositionNotify[2]; if(lpdsb->QueryInterface(IID_IDirectSoundNotify,(LPVOID *)&lpDsNotify)==E_NOINTERFACE ) exit(0); h1 = CreateEvent(NULL, FALSE, FALSE, NULL); h2 = CreateEvent(NULL, FALSE, FALSE, NULL); PositionNotify[0].dwOffset = soundBufferSize/4; PositionNotify[0].hEventNotify = h1; PositionNotify[1].dwOffset = soundBufferSize*3/4; PositionNotify[1].hEventNotify = h2; if(lpDsNotify->SetNotificationPositions(2, PositionNotify)!=DS_OK) exit(0); then create a new threaded function to handle those events: //function to handle music loops notifications DWORD HandleNotifications(LPVOID lpvoid) { Sleep(0); DWORD hRet = 0; while((hRet = WaitForMultipleObjects(2, hNotifyEvent, FALSE, INFINITE))!= WAIT_FAILED) { switch(hRet-WAIT_OBJECT_0) { case 0: //load first buffer half buffer1->GetMore(); break; case 1: //load second buffer half buffer1->GetMore(); break; }// end switch } // while return 0; } any help?

Share this post


Link to post
Share on other sites
Advertisement

  • 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!