Sign in to follow this  

DirectSound - Secondary Buffer SetFormat fails

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

SetFormat function call gives error code 0x88780032. It works just fine with Primary Buffer.

 

Before SetFormat() call debuging shows following values:

 

BufferDescription.dwSize = 40
BufferDescription.dwFlags = 0;
BufferDescription.dwBufferBytes = 192000

 

WaveFormat.wFormatTag = 1
WaveFormat.nChannels = 2
WaveFormat.nSamplesPerSec = 48000
WaveFormat.wBitsPerSample = 16
WaveFormat.nBlockAlign = 4
WaveFormat.nAvgBytesPerSec = 192000
WaveFormat.cbSize = 0;

 

This is from Handmade Hero series (Day 7).

WAVEFORMATEX WaveFormat = {};
WaveFormat.wFormatTag = WAVE_FORMAT_PCM;
WaveFormat.nChannels = 2;
WaveFormat.nSamplesPerSec = SamplesPerSecond;
WaveFormat.wBitsPerSample = 16;
WaveFormat.nBlockAlign = (WaveFormat.nChannels * WaveFormat.wBitsPerSample) / 8;
WaveFormat.nAvgBytesPerSec = WaveFormat.nBlockAlign * WaveFormat.nSamplesPerSec;
WaveFormat.cbSize = 0;

DSBUFFERDESC BufferDescription = {};
BufferDescription.dwSize = sizeof(BufferDescription);
BufferDescription.dwFlags = 0;
BufferDescription.dwBufferBytes = BufferSize;
BufferDescription.lpwfxFormat = &WaveFormat;

LPDIRECTSOUNDBUFFER SecondaryBuffer;
if (SUCCEEDED(DirectSound->CreateSoundBuffer(&BufferDescription, &SecondaryBuffer, 0)))
{
	HRESULT Error = SecondaryBuffer->SetFormat(&WaveFormat);
	if (SUCCEEDED(Error))
	{
		OutputDebugStringA("SecondaryBuffer is fine!\n");
	}

Share this post


Link to post
Share on other sites

This topic is 411 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this