OpenAL sound device configuration.
This commit is contained in:
parent
730694644d
commit
8f32899afd
|
@ -22,7 +22,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public OpenALSoundOutput(Sound sound)
|
public OpenALSoundOutput(Sound sound)
|
||||||
{
|
{
|
||||||
_sound = sound;
|
_sound = sound;
|
||||||
_context = new AudioContext();
|
string deviceName = GetDeviceNames().FirstOrDefault(n => n == Global.Config.SoundDevice);
|
||||||
|
_context = new AudioContext(deviceName, Sound.SampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -35,6 +36,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<string> GetDeviceNames()
|
||||||
|
{
|
||||||
|
if (!Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT")) return Enumerable.Empty<string>();
|
||||||
|
return Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier);
|
||||||
|
}
|
||||||
|
|
||||||
private int BufferSizeSamples { get; set; }
|
private int BufferSizeSamples { get; set; }
|
||||||
|
|
||||||
public int MaxSamplesDeficit { get; private set; }
|
public int MaxSamplesDeficit { get; private set; }
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var oldOutputMethod = Global.Config.SoundOutputMethod;
|
var oldOutputMethod = Global.Config.SoundOutputMethod;
|
||||||
|
var oldDevice = Global.Config.SoundDevice;
|
||||||
Global.Config.SoundEnabled = SoundOnCheckBox.Checked;
|
Global.Config.SoundEnabled = SoundOnCheckBox.Checked;
|
||||||
Global.Config.MuteFrameAdvance = MuteFrameAdvance.Checked;
|
Global.Config.MuteFrameAdvance = MuteFrameAdvance.Checked;
|
||||||
if (rbOutputMethodDirectSound.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
if (rbOutputMethodDirectSound.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
||||||
|
@ -54,7 +55,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.Config.SoundVolume = SoundVolBar.Value;
|
Global.Config.SoundVolume = SoundVolBar.Value;
|
||||||
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
if (Global.Config.SoundOutputMethod != oldOutputMethod)
|
if (Global.Config.SoundOutputMethod != oldOutputMethod ||
|
||||||
|
Global.Config.SoundDevice != oldDevice)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.Dispose();
|
GlobalWin.Sound.Dispose();
|
||||||
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
||||||
|
@ -77,6 +79,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
||||||
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
||||||
#endif
|
#endif
|
||||||
|
if (rbOutputMethodOpenAL.Checked) deviceNames = OpenALSoundOutput.GetDeviceNames();
|
||||||
listBoxSoundDevices.Items.Clear();
|
listBoxSoundDevices.Items.Clear();
|
||||||
listBoxSoundDevices.Items.Add("<default>");
|
listBoxSoundDevices.Items.Add("<default>");
|
||||||
listBoxSoundDevices.SelectedIndex = 0;
|
listBoxSoundDevices.SelectedIndex = 0;
|
||||||
|
|
Loading…
Reference in New Issue