1 2 3 4 5 6 7 8 | 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; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | DSBUFFERDESC BufferDescription = {}; BufferDescription.dwSize = sizeof(BufferDescription); BufferDescription.dwFlags = 0; BufferDescription.dwBufferBytes = BufferSize; BufferDescription.lpwfxFormat = &WaveFormat; // Create a secondary buffer LPDIRECTSOUNDBUFFER SecondaryBuffer; if (SUCCEEDED(DirectSound->CreateSoundBuffer(&BufferDescription, &SecondaryBuffer, 0))) { HRESULT Error = SecondaryBuffer->SetFormat(&WaveFormat); if (SUCCEEDED(Error)) { OutputDebugStringA("SecondaryBuffer is fine!\n"); } |
This gives error code 0x88780032. I have no problems with Primary Buffer.
Buffersize = 48000 * sizeof(int16) * 2 = 192000.
SamplesPerSecond = 48000.