Add properties to IHostAudioManager for accessing global config
This commit is contained in:
parent
e1daa7efd3
commit
4c8bdf9851
|
@ -8,6 +8,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
int ChannelCount { get; }
|
||||
|
||||
int ConfigBufferSizeMs { get; }
|
||||
|
||||
string ConfigDevice { get; }
|
||||
|
||||
int SampleRate { get; }
|
||||
|
||||
void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded);
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void StartSound()
|
||||
{
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(_sound.ConfigBufferSizeMs);
|
||||
|
||||
// 35 to 65 milliseconds depending on how big the buffer is. This is a trade-off
|
||||
// between more frequent but less severe glitches (i.e. catching underruns before
|
||||
|
@ -144,7 +144,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// severe glitches. At least on my Windows 8 machines, the distance between the
|
||||
// play and write cursors can be up to 30 milliseconds, so that would be the
|
||||
// absolute minimum we could use here.
|
||||
int minBufferFullnessMs = Math.Min(35 + ((GlobalWin.Config.SoundBufferSizeMs - 60) / 2), 65);
|
||||
int minBufferFullnessMs = Math.Min(35 + ((_sound.ConfigBufferSizeMs - 60) / 2), 65);
|
||||
MaxSamplesDeficit = BufferSizeSamples - _sound.MillisecondsToSamples(minBufferFullnessMs);
|
||||
|
||||
StartPlaying();
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void StartSound()
|
||||
{
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(_sound.ConfigBufferSizeMs);
|
||||
MaxSamplesDeficit = BufferSizeSamples;
|
||||
|
||||
_lastWriteTime = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public OpenALSoundOutput(IHostAudioManager sound)
|
||||
{
|
||||
_sound = sound;
|
||||
string deviceName = GetDeviceNames().FirstOrDefault(n => n == GlobalWin.Config.SoundDevice);
|
||||
string deviceName = GetDeviceNames().FirstOrDefault(n => n == _sound.ConfigDevice);
|
||||
_context = new AudioContext(deviceName, _sound.SampleRate);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void StartSound()
|
||||
{
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(_sound.ConfigBufferSizeMs);
|
||||
MaxSamplesDeficit = BufferSizeSamples;
|
||||
|
||||
_sourceID = AL.GenSource();
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_device = new XAudio2();
|
||||
int? deviceIndex = Enumerable.Range(0, _device.DeviceCount)
|
||||
.Select(n => (int?)n)
|
||||
.FirstOrDefault(n => _device.GetDeviceDetails(n.Value).DisplayName == GlobalWin.Config.SoundDevice);
|
||||
.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);
|
||||
|
@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void StartSound()
|
||||
{
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(GlobalWin.Config.SoundBufferSizeMs);
|
||||
BufferSizeSamples = _sound.MillisecondsToSamples(_sound.ConfigBufferSizeMs);
|
||||
MaxSamplesDeficit = BufferSizeSamples;
|
||||
|
||||
var format = new WaveFormat
|
||||
|
|
|
@ -24,6 +24,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
private readonly BufferedAsync _bufferedAsync = new BufferedAsync(); // Buffer for Async sources
|
||||
private IBufferedSoundProvider _bufferedProvider; // One of the preceding buffers, or null if no source is set
|
||||
|
||||
public int ConfigBufferSizeMs => GlobalWin.Config.SoundBufferSizeMs;
|
||||
|
||||
public string ConfigDevice => GlobalWin.Config.SoundDevice;
|
||||
|
||||
public Sound(IntPtr mainWindowHandle)
|
||||
{
|
||||
BlockAlign = BytesPerSample * ChannelCount;
|
||||
|
|
Loading…
Reference in New Issue