Skip to content

Commit

Permalink
changed try/catch in a way it still continues adding samplerates even…
Browse files Browse the repository at this point in the history
… after one of them failed
  • Loading branch information
joreg committed Nov 5, 2024
1 parent e7cb612 commit 6e40c65
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions VL.Audio/src/VL/AudioSampleRateEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ protected override IReadOnlyDictionary<string, object> GetEntries()
{
var samplingRates = new Dictionary<string, object>();

try
{
foreach (var item in Enum.GetValues(typeof(AudioSampleRateEnum)))
foreach (var item in Enum.GetValues(typeof(AudioSampleRateEnum)))
try
{
if (AudioService.Engine?.IsSampleRateSupported((int)item) ?? false)
samplingRates.Add(((int)item).ToString(), (int)item);
}
catch
{
//Realtek ASIO drivers seem to fail getting samplerates, but 48000 still works
if (samplingRates.None())
samplingRates.Add("48000", 48000);
}
samplingRates.Add(((int)item).ToString(), (int)item);
}
catch
{
}

return samplingRates;
}
Expand Down

0 comments on commit 6e40c65

Please sign in to comment.