From 46d0b2e2f6d1da12e21b34eae29e329a4e5bb9a2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 14 Aug 2004 19:53:15 +0000 Subject: [PATCH] cleanup; check primary buffer format --- stepmania/src/arch/Sound/DSoundHelpers.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/stepmania/src/arch/Sound/DSoundHelpers.cpp b/stepmania/src/arch/Sound/DSoundHelpers.cpp index a841ad6193..90df186bea 100644 --- a/stepmania/src/arch/Sound/DSoundHelpers.cpp +++ b/stepmania/src/arch/Sound/DSoundHelpers.cpp @@ -57,19 +57,27 @@ void DSound::SetPrimaryBufferMode() } WAVEFORMATEX waveformat; + memset( &waveformat, 0, sizeof(waveformat) ); waveformat.cbSize = 0; waveformat.wFormatTag = WAVE_FORMAT_PCM; - waveformat.wBitsPerSample = WORD(16); - waveformat.nChannels = WORD(2); - waveformat.nSamplesPerSec = DWORD(44100); - waveformat.nBlockAlign = WORD(4); - waveformat.nAvgBytesPerSec = 44100 * waveformat.nBlockAlign; + waveformat.wBitsPerSample = 16; + waveformat.nChannels = 2; + waveformat.nSamplesPerSec = 44100; + waveformat.nBlockAlign = 4; + waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec * waveformat.nBlockAlign; // Set the primary buffer's format hr = IDirectSoundBuffer_SetFormat( buf, &waveformat ); if( FAILED(hr) ) LOG->Warn( hr_ssprintf(hr, "SetFormat on primary buffer") ); + DWORD got; + hr = buf->GetFormat( &waveformat, sizeof(waveformat), &got ); + if( FAILED(hr) ) + LOG->Warn( hr_ssprintf(hr, "GetFormat on primary buffer") ); + else if( waveformat.nSamplesPerSec != 44100 ) + LOG->Warn( hr_ssprintf(hr, "Primary buffer set to %i instead of 44100", waveformat.nSamplesPerSec) ); + /* MS docs: * * When there are no sounds playing, DirectSound stops the mixer engine and halts DMA @@ -181,7 +189,7 @@ DSoundBuf::DSoundBuf( DSound &ds, DSoundBuf::hw hardware, WAVEFORMATEX waveformat; memset( &waveformat, 0, sizeof(waveformat) ); - waveformat.cbSize = sizeof(waveformat); + waveformat.cbSize = 0; waveformat.wFormatTag = WAVE_FORMAT_PCM; bool NeedCtrlFrequency = false;