CreateSoundBuffer failed
Hallo everyone! I have some strange problem - I create several sound buffers, but for some sounds CreateSoundBuffer returns E_FAIL. Why it hapens I don't know - all buffers are created in the same function, by same way... Please, help me fix this problem.
Ok, here
LPDIRECTSOUNDBUFFER buffer;
// open wave file and create buffer
if( FAILED(r.Open(pFileName)) ) return NULL;
// fail if no PCM
if( r.m_pwfx->wFormatTag!=WAVE_FORMAT_PCM ) return NULL;
DSBUFFERDESC dsbd;
ZeroMemory ( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STATIC | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | (b3D?DSBCAPS_CTRL3D|DSBCAPS_MUTE3DATMAXDISTANCE:0);
dsbd.dwBufferBytes = r.m_ckIn.cksize;
dsbd.lpwfxFormat = r.m_pwfx;
dsbd.guid3DAlgorithm= DS3DALG_DEFAULT;
HRESULT hr = g_pDS->CreateSoundBuffer(&dsbd,&buffer,NULL);
if ( hr != DS_OK )
return NULL;
I think that course of problem - is flag - DSBCAPS_LOCHARDWARE. But why first several sounds are loading ok, and another sounds not?
LPDIRECTSOUNDBUFFER buffer;
// open wave file and create buffer
if( FAILED(r.Open(pFileName)) ) return NULL;
// fail if no PCM
if( r.m_pwfx->wFormatTag!=WAVE_FORMAT_PCM ) return NULL;
DSBUFFERDESC dsbd;
ZeroMemory ( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_STATIC | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | (b3D?DSBCAPS_CTRL3D|DSBCAPS_MUTE3DATMAXDISTANCE:0);
dsbd.dwBufferBytes = r.m_ckIn.cksize;
dsbd.lpwfxFormat = r.m_pwfx;
dsbd.guid3DAlgorithm= DS3DALG_DEFAULT;
HRESULT hr = g_pDS->CreateSoundBuffer(&dsbd,&buffer,NULL);
if ( hr != DS_OK )
return NULL;
I think that course of problem - is flag - DSBCAPS_LOCHARDWARE. But why first several sounds are loading ok, and another sounds not?
From the SDK:
Quote:DSBCAPS_LOCHARDWARE - The buffer uses hardware mixing.Have you checked how many buffers your sound card can mix in hardware (DSCAPS::dwMaxHwMixingStaticBuffers)?
Quote:DSBCAPS_LOCHARDWARE - The buffer uses hardware mixing. Have you checked how many buffers your sound card can mix in hardware (DSCAPS::dwMaxHwMixingStaticBuffers)?
Yes! Thats it, I checked the maxuimum number of buffers - 26. But I need more for my EAX aplication. How can I be?
Quote:Original post by moverokYou can create the buffers in software instead of hardware. I'd advise that you use hardware buffers for buffers that need to have EAX effects applied to them, and software for the rest. I think you can still do EAX effects in software (I could be wrong, I've never used them), but it'll be slower. But if that's a problem, you shouldn't be using 26 EAX buffers anyway.Quote:DSBCAPS_LOCHARDWARE - The buffer uses hardware mixing. Have you checked how many buffers your sound card can mix in hardware (DSCAPS::dwMaxHwMixingStaticBuffers)?
Yes! Thats it, I checked the maxuimum number of buffers - 26. But I need more for my EAX aplication. How can I be?
Quote:Original post by Evil Steve
...But if that's a problem, you shouldn't be using 26 EAX buffers anyway.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement