Clean up some dumb in *SoundOutput ctors
This commit is contained in:
parent
9e5ab0706e
commit
edda120b07
|
@ -20,16 +20,19 @@ namespace BizHawk.Bizware.DirectX
|
|||
private BufferPool _bufferPool;
|
||||
private long _runningSamplesQueued;
|
||||
|
||||
public XAudio2SoundOutput(IHostAudioManager sound)
|
||||
public XAudio2SoundOutput(IHostAudioManager sound, string chosenDeviceName)
|
||||
{
|
||||
_sound = sound;
|
||||
_device = new XAudio2();
|
||||
int? deviceIndex = Enumerable.Range(0, _device.DeviceCount)
|
||||
.Select(n => (int?)n)
|
||||
.FirstOrDefault(n => _device.GetDeviceDetails(n.Value).DisplayName == _sound.ConfigDevice);
|
||||
_masteringVoice = deviceIndex == null ?
|
||||
new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate) :
|
||||
new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate, deviceIndex.Value);
|
||||
for (int i = 0, l = _device.DeviceCount; i < l; i++)
|
||||
{
|
||||
if (_device.GetDeviceDetails(i).DisplayName == chosenDeviceName)
|
||||
{
|
||||
_masteringVoice = new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_masteringVoice = new MasteringVoice(_device, _sound.ChannelCount, _sound.SampleRate);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
int ConfigBufferSizeMs { get; }
|
||||
|
||||
string ConfigDevice { get; }
|
||||
|
||||
int SampleRate { get; }
|
||||
|
||||
void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded);
|
||||
|
|
|
@ -19,11 +19,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
private int _currentSamplesQueued;
|
||||
private short[] _tempSampleBuffer;
|
||||
|
||||
public OpenALSoundOutput(IHostAudioManager sound)
|
||||
public OpenALSoundOutput(IHostAudioManager sound, string chosenDeviceName)
|
||||
{
|
||||
_sound = sound;
|
||||
string deviceName = GetDeviceNames().FirstOrDefault(n => n == _sound.ConfigDevice);
|
||||
_context = new AudioContext(deviceName, _sound.SampleRate);
|
||||
_context = new AudioContext(
|
||||
GetDeviceNames().Contains(chosenDeviceName) ? chosenDeviceName : null,
|
||||
_sound.SampleRate
|
||||
);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public int ConfigBufferSizeMs => GlobalWin.Config.SoundBufferSizeMs;
|
||||
|
||||
public string ConfigDevice => GlobalWin.Config.SoundDevice;
|
||||
|
||||
public Sound(IntPtr mainWindowHandle)
|
||||
{
|
||||
BlockAlign = BytesPerSample * ChannelCount;
|
||||
|
@ -38,15 +36,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
// if DirectSound or XAudio is chosen, use OpenAL, otherwise comply with the user's choice
|
||||
_outputDevice = GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.Dummy
|
||||
? (ISoundOutput) new DummySoundOutput(this)
|
||||
: new OpenALSoundOutput(this);
|
||||
: new OpenALSoundOutput(this, GlobalWin.Config.SoundDevice);
|
||||
}
|
||||
else
|
||||
{
|
||||
_outputDevice = GlobalWin.Config.SoundOutputMethod switch
|
||||
{
|
||||
ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, GlobalWin.Config.SoundDevice),
|
||||
ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this),
|
||||
ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this),
|
||||
ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this, GlobalWin.Config.SoundDevice),
|
||||
ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this, GlobalWin.Config.SoundDevice),
|
||||
_ => new DummySoundOutput(this)
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue