From 8f32899afdd3caba697f0d3f5e6aa3be4762072d Mon Sep 17 00:00:00 2001 From: jdpurcell Date: Thu, 19 Feb 2015 06:00:07 +0000 Subject: [PATCH] OpenAL sound device configuration. --- BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs | 9 ++++++++- BizHawk.Client.EmuHawk/config/SoundConfig.cs | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs index 588c59da1d..283123398c 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/OpenALSoundOutput.cs @@ -22,7 +22,8 @@ namespace BizHawk.Client.EmuHawk public OpenALSoundOutput(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() @@ -35,6 +36,12 @@ namespace BizHawk.Client.EmuHawk _disposed = true; } + public static IEnumerable GetDeviceNames() + { + if (!Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT")) return Enumerable.Empty(); + return Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier); + } + private int BufferSizeSamples { get; set; } public int MaxSamplesDeficit { get; private set; } diff --git a/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 803d9c5ca1..1e3180377e 100644 --- a/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -45,6 +45,7 @@ namespace BizHawk.Client.EmuHawk return; } var oldOutputMethod = Global.Config.SoundOutputMethod; + var oldDevice = Global.Config.SoundDevice; Global.Config.SoundEnabled = SoundOnCheckBox.Checked; Global.Config.MuteFrameAdvance = MuteFrameAdvance.Checked; if (rbOutputMethodDirectSound.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound; @@ -54,7 +55,8 @@ namespace BizHawk.Client.EmuHawk Global.Config.SoundVolume = SoundVolBar.Value; Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? ""; GlobalWin.Sound.StopSound(); - if (Global.Config.SoundOutputMethod != oldOutputMethod) + if (Global.Config.SoundOutputMethod != oldOutputMethod || + Global.Config.SoundDevice != oldDevice) { GlobalWin.Sound.Dispose(); GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle); @@ -77,6 +79,7 @@ namespace BizHawk.Client.EmuHawk if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames(); if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames(); #endif + if (rbOutputMethodOpenAL.Checked) deviceNames = OpenALSoundOutput.GetDeviceNames(); listBoxSoundDevices.Items.Clear(); listBoxSoundDevices.Items.Add(""); listBoxSoundDevices.SelectedIndex = 0;