Archived

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

Having a problem with SetNoficationPositions in DirectSound

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

I''m getting an error message when trying to set the notification positions in a secondary directsoundbuffer. The HRESULT error reportet is E_OUTOFMEMORY. Heres the code: HRESULT hResult; WAVEFORMATEX sWaveFormat; DSBUFFERDESC sDSBufferDesc; IDirectSoundBuffer *pBuffer; HANDLE hHandle; DSBPOSITIONNOTIFY *sDSPositionNotify; sDSPositionNotify = new DSBPOSITIONNOTIFY[4]; // Fill out the wave format struct ZeroMemory(&sWaveFormat, sizeof(WAVEFORMATEX)); sWaveFormat.wFormatTag = WAVE_FORMAT_PCM; sWaveFormat.nChannels = iChannels; sWaveFormat.nSamplesPerSec = dwFrequency; sWaveFormat.nBlockAlign = (iBitsPerSample / 8) *iChannels; sWaveFormat.nAvgBytesPerSec = dwFrequency * sWaveFormat.nBlockAlign; sWaveFormat.wBitsPerSample = iBitsPerSample; // Fill out the Direct Sound description struct ZeroMemory(&sDSBufferDesc, sizeof(DSBUFFERDESC)); sDSBufferDesc.dwSize = sizeof(DSBUFFERDESC); sDSBufferDesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_LOCSOFTWARE; sDSBufferDesc.dwBufferBytes = DSBUFFERSIZE; // 65536 bytes sDSBufferDesc.guid3DAlgorithm = GUID_NULL; sDSBufferDesc.lpwfxFormat = &sWaveFormat; // GetDirectSoundCOM returns an IDirectSound8 interface if(FAILED(hResult = m_pSound->GetDirectSoundCOM()->CreateSoundBuffer(&sDSBufferDesc, &m_pDSBuffer, 0))) { return hResult; } if(FAILED(hResult = m_pDSBuffer->QueryInterface(IID_IDirectSoundNotify8, (void**)&m_pDSNotify))) { return hResult; } m_pSound->AssignEvent(this, &m_iEvent, &hHandle); // DSCHUNKSIZE = 16384 sDSPositionNotify[0].dwOffset = DSCHUNKSIZE * 1 - 1; sDSPositionNotify[0].hEventNotify = &hHandle; sDSPositionNotify[1].dwOffset = DSCHUNKSIZE * 2 - 1; sDSPositionNotify[1].hEventNotify = &hHandle; sDSPositionNotify[2].dwOffset = DSCHUNKSIZE * 3 - 1; sDSPositionNotify[2].hEventNotify = &hHandle; sDSPositionNotify[3].dwOffset = DSCHUNKSIZE * 4 - 1; sDSPositionNotify[3].hEventNotify = &hHandle; // Fails here if(FAILED(hResult = m_pDSNotify->SetNotificationPositions(4, sDSPositionNotify))) { return hResult; } This should be quite similar to the microsoft sample code, so I''m not sure what''s going on here.

Share this post


Link to post
Share on other sites
I am not familiar with the ->AssignEvent() function, otherwise things look pretty good. I use the Windows API function: hevent = CreateEvent(NULL, FALSE, FALSE, NULL); //Create event object unsignaled
to create the event and it worked without a problem. Could it be a problem with the event handle? My Direct SOund version must be too old; I can''t find that function anywhere so I have no information on what it does or how it might work.

Brian

Share this post


Link to post
Share on other sites