-Potential fix for the sound hardware issue

This commit is contained in:
cyberwarriorx 2007-01-17 03:19:08 +00:00
parent c9573f973d
commit f43c172cff
1 changed files with 4 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005-2006 Theo Berkau /* Copyright (C) 2005-2007 Theo Berkau
This file is part of DeSmuME This file is part of DeSmuME
@ -17,9 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#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
@ -65,7 +62,6 @@ static int issoundmuted;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int SNDDXInit(int buffersize) int SNDDXInit(int buffersize)
{ {
DSBUFFERDESC dsbdesc; DSBUFFERDESC dsbdesc;
@ -128,7 +124,8 @@ int SNDDXInit(int buffersize)
if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK)
{ {
if (ret == DSERR_CONTROLUNAVAIL || if (ret == DSERR_CONTROLUNAVAIL ||
ret == DSERR_INVALIDCALL) ret == DSERR_INVALIDCALL ||
ret == E_FAIL)
{ {
// Try using a software buffer instead // Try using a software buffer instead
dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS |
@ -165,7 +162,6 @@ int SNDDXInit(int buffersize)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXDeInit() void SNDDXDeInit()
{ {
DWORD status=0; DWORD status=0;
@ -196,7 +192,6 @@ void SNDDXDeInit()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXUpdateAudio(s16 *buffer, u32 num_samples) void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
{ {
LPVOID buffer1; LPVOID buffer1;
@ -223,7 +218,6 @@ void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
u32 SNDDXGetAudioSpace() u32 SNDDXGetAudioSpace()
{ {
DWORD playcursor, writecursor; DWORD playcursor, writecursor;
@ -245,7 +239,6 @@ u32 SNDDXGetAudioSpace()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXMuteAudio() void SNDDXMuteAudio()
{ {
issoundmuted = 1; issoundmuted = 1;
@ -254,7 +247,6 @@ void SNDDXMuteAudio()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXUnMuteAudio() void SNDDXUnMuteAudio()
{ {
issoundmuted = 0; issoundmuted = 0;
@ -263,10 +255,9 @@ void SNDDXUnMuteAudio()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void SNDDXSetVolume(int volume) void SNDDXSetVolume(int volume)
{ {
if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */ 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);