From c4c2204f6c5af113b78a3f22c32a92ea8b9b2885 Mon Sep 17 00:00:00 2001 From: OV2 Date: Mon, 4 Oct 2010 17:33:42 +0200 Subject: [PATCH] Fix access violations on systems with no sound card (Brian Friesen) --- win32/CDirectSound.h | 4 ++-- win32/win32_sound.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/win32/CDirectSound.h b/win32/CDirectSound.h index e5f89f01..d1b80e7d 100644 --- a/win32/CDirectSound.h +++ b/win32/CDirectSound.h @@ -199,9 +199,9 @@ private: int blockCount; // number of blocks in the buffer int blockSize; // bytes in one block - int blockSamples; + int blockSamples; // samples in one block int bufferSize; // bytes in the whole buffer - int blockTime; + int blockTime; // ms in one block DWORD last_block; // the last block that was mixed diff --git a/win32/win32_sound.cpp b/win32/win32_sound.cpp index 04ddf959..55cae453 100644 --- a/win32/win32_sound.cpp +++ b/win32/win32_sound.cpp @@ -239,6 +239,7 @@ returns true if successful, false otherwise */ bool8 S9xOpenSoundDevice () { + S9xSetSamplesAvailableCallback (NULL, NULL); // point the interface to the correct output object switch(GUI.SoundDriver) { case WIN_SNES9X_DIRECT_SOUND_DRIVER: @@ -266,8 +267,12 @@ bool8 S9xOpenSoundDevice () } if(!S9xSoundOutput->InitSoundOutput()) return false; + + if(!S9xSoundOutput->SetupSound()) + return false; + S9xSetSamplesAvailableCallback (S9xSoundCallback, NULL); - return S9xSoundOutput->SetupSound(); + return true; } /* S9xSoundCallback