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:
parent
bdfb144695
commit
629f89e81b
|
@ -16,8 +16,10 @@
|
||||||
along with DeSmuME; if not, write to the Free Software
|
along with DeSmuME; if not, write to the Free Software
|
||||||
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
|
||||||
|
@ -61,7 +63,8 @@ static u32 soundbufsize;
|
||||||
static LONG soundvolume;
|
static LONG soundvolume;
|
||||||
static int issoundmuted;
|
static int issoundmuted;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
int SNDDXInit(int buffersize)
|
int SNDDXInit(int buffersize)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +163,8 @@ int SNDDXInit(int buffersize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void SNDDXDeInit()
|
void SNDDXDeInit()
|
||||||
{
|
{
|
||||||
|
@ -190,7 +194,8 @@ void SNDDXDeInit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
|
void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
|
||||||
{
|
{
|
||||||
|
@ -216,7 +221,8 @@ void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
|
||||||
IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size);
|
IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
u32 SNDDXGetAudioSpace()
|
u32 SNDDXGetAudioSpace()
|
||||||
{
|
{
|
||||||
|
@ -237,7 +243,8 @@ u32 SNDDXGetAudioSpace()
|
||||||
// return 0;
|
// return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void SNDDXMuteAudio()
|
void SNDDXMuteAudio()
|
||||||
{
|
{
|
||||||
|
@ -245,7 +252,8 @@ void SNDDXMuteAudio()
|
||||||
IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN);
|
IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void SNDDXUnMuteAudio()
|
void SNDDXUnMuteAudio()
|
||||||
{
|
{
|
||||||
|
@ -253,14 +261,17 @@ void SNDDXUnMuteAudio()
|
||||||
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
|
IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue