survive dsound initialization failure
This commit is contained in:
parent
49eb8272f9
commit
e41f9d2a41
|
@ -19,8 +19,7 @@ namespace BizHawk.MultiClient
|
||||||
try { Global.DSound = new DirectSound(); }
|
try { Global.DSound = new DirectSound(); }
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
MessageBox.Show("Couldn't initialize DirectSound!", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 41khz instead of 48khz in mmsys.cpl.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try { Global.Direct3D = new Direct3D(); }
|
try { Global.Direct3D = new Direct3D(); }
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace BizHawk.MultiClient
|
||||||
private BufferedAsync semisync = new BufferedAsync();
|
private BufferedAsync semisync = new BufferedAsync();
|
||||||
|
|
||||||
public Sound(IntPtr handle, DirectSound device)
|
public Sound(IntPtr handle, DirectSound device)
|
||||||
|
{
|
||||||
|
if (device != null)
|
||||||
{
|
{
|
||||||
device.SetCooperativeLevel(handle, CooperativeLevel.Priority);
|
device.SetCooperativeLevel(handle, CooperativeLevel.Priority);
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ namespace BizHawk.MultiClient
|
||||||
desc.SizeInBytes = BufferSize;
|
desc.SizeInBytes = BufferSize;
|
||||||
DSoundBuffer = new SecondarySoundBuffer(device, desc);
|
DSoundBuffer = new SecondarySoundBuffer(device, desc);
|
||||||
ChangeVolume(Global.Config.SoundVolume);
|
ChangeVolume(Global.Config.SoundVolume);
|
||||||
|
}
|
||||||
SoundBuffer = new byte[BufferSize];
|
SoundBuffer = new byte[BufferSize];
|
||||||
|
|
||||||
disposed = false;
|
disposed = false;
|
||||||
|
@ -47,7 +50,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
if (disposed) throw new ObjectDisposedException("Sound");
|
if (disposed) throw new ObjectDisposedException("Sound");
|
||||||
if (Global.Config.SoundEnabled == false) return;
|
if (Global.Config.SoundEnabled == false) return;
|
||||||
|
if (DSoundBuffer == null) return;
|
||||||
if (IsPlaying)
|
if (IsPlaying)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -101,6 +104,8 @@ namespace BizHawk.MultiClient
|
||||||
int soundoffset;
|
int soundoffset;
|
||||||
int SNDDXGetAudioSpace()
|
int SNDDXGetAudioSpace()
|
||||||
{
|
{
|
||||||
|
if (DSoundBuffer == null) return 0;
|
||||||
|
|
||||||
int playcursor = DSoundBuffer.CurrentPlayPosition;
|
int playcursor = DSoundBuffer.CurrentPlayPosition;
|
||||||
int writecursor = DSoundBuffer.CurrentWritePosition;
|
int writecursor = DSoundBuffer.CurrentWritePosition;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue