fixed crash when changing to a errornous sounddevice (i.e. the change from wav-writer to directsound which returned E-Fail)

This commit is contained in:
mightymax 2007-01-09 16:30:41 +00:00
parent bdfb144695
commit 629f89e81b
1 changed files with 21 additions and 10 deletions

View File

@ -18,6 +18,8 @@
*/ */
#include <dsound.h> #include <dsound.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
// I have to do this because for some reason because the dxerr8.h header is fubared // I have to do this because for some reason because the dxerr8.h header is fubared
@ -63,6 +65,7 @@ static int issoundmuted;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int SNDDXInit(int buffersize) int SNDDXInit(int buffersize)
{ {
DSBUFFERDESC dsbdesc; DSBUFFERDESC dsbdesc;
@ -162,6 +165,7 @@ int SNDDXInit(int buffersize)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXDeInit() void SNDDXDeInit()
{ {
DWORD status=0; DWORD status=0;
@ -192,6 +196,7 @@ void SNDDXDeInit()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXUpdateAudio(s16 *buffer, u32 num_samples) void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
{ {
LPVOID buffer1; LPVOID buffer1;
@ -218,6 +223,7 @@ void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
u32 SNDDXGetAudioSpace() u32 SNDDXGetAudioSpace()
{ {
DWORD playcursor, writecursor; DWORD playcursor, writecursor;
@ -239,6 +245,7 @@ u32 SNDDXGetAudioSpace()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXMuteAudio() void SNDDXMuteAudio()
{ {
issoundmuted = 1; issoundmuted = 1;
@ -247,6 +254,7 @@ void SNDDXMuteAudio()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXUnMuteAudio() void SNDDXUnMuteAudio()
{ {
issoundmuted = 0; issoundmuted = 0;
@ -255,8 +263,10 @@ void SNDDXUnMuteAudio()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXSetVolume(int volume) void SNDDXSetVolume(int volume)
{ {
if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */
soundvolume = (((LONG)volume) - 100) * 100; soundvolume = (((LONG)volume) - 100) * 100;
if (!issoundmuted) if (!issoundmuted)
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
@ -264,3 +274,4 @@ void SNDDXSetVolume(int volume)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////