what exactly does DSERR_INVALIDPARAM mean?
I''m getting a DSERR_INVALIDPARAM error handle from CreateSoundBuffer (). Could this mean that some of the variables in DSBUFFERDESC are initialized wrong, or does it mean that I''m passing bad structures?
It could mean either of these things.
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
Here''s the code that causes the error:
// Theses four variables are what are actually sent to
// the function. I just gave them example values.
unsigned long size = 44100;
unsigned long hz = 22050;
unsigned short channels = 2;
unsigned short bits = 16;
HRESULT hr;
DSBUFFERDESC dsbd;
WAVEFORMATEX wfx;
memset (&dsbd, 0, sizeof (dsbd));
dsbd.dwSize = sizeof (dsbd);
dsbd.dwFlags = DSBCAPS_STATIC;
dsbd.dwBufferBytes = size;
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = channels;
wfx.nSamplesPerSec = hz;
wfx.wBitsPerSample = bits;
wfx.nAvgBytesPerSec = (unsigned long)(hz * ((channels * bits) / 8));
wfx.cbSize = 0;
dsbd.lpwfxFormat = &wfx
hr = lpds->CreateSoundBuffer (&dsbd, &lpdss, NULL);
// Theses four variables are what are actually sent to
// the function. I just gave them example values.
unsigned long size = 44100;
unsigned long hz = 22050;
unsigned short channels = 2;
unsigned short bits = 16;
HRESULT hr;
DSBUFFERDESC dsbd;
WAVEFORMATEX wfx;
memset (&dsbd, 0, sizeof (dsbd));
dsbd.dwSize = sizeof (dsbd);
dsbd.dwFlags = DSBCAPS_STATIC;
dsbd.dwBufferBytes = size;
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = channels;
wfx.nSamplesPerSec = hz;
wfx.wBitsPerSample = bits;
wfx.nAvgBytesPerSec = (unsigned long)(hz * ((channels * bits) / 8));
wfx.cbSize = 0;
dsbd.lpwfxFormat = &wfx
hr = lpds->CreateSoundBuffer (&dsbd, &lpdss, NULL);
Also, look out to make sure you aren''t passing a pointer to a struct when it expects a pointer to a pointer to a struct Or vice versa.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement