Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions osu.Framework/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
public readonly AudioMixer SampleMixer;

/// <summary>
/// The names of all available audio devices.
/// All available audio device names along with their driver names.
/// </summary>
/// <remarks>
/// <para>
Expand All @@ -80,7 +80,7 @@
/// Consumers should provide a "Default" audio device entry which sets <see cref="AudioDevice"/> to an empty string.
/// </para>
/// </remarks>
public IEnumerable<string> AudioDeviceNames => audioDeviceNames;
public IEnumerable<(string Name, string Driver)> AudioDeviceNames => audioDeviceNames;

/// <summary>
/// Is fired whenever a new audio device is discovered and provides its name.
Expand Down Expand Up @@ -153,7 +153,7 @@

// Mutated by multiple threads, must be thread safe.
private ImmutableArray<DeviceInfo> audioDevices = ImmutableArray<DeviceInfo>.Empty;
private ImmutableList<string> audioDeviceNames = ImmutableList<string>.Empty;
private ImmutableList<(string Name, string Driver)> audioDeviceNames = ImmutableList<(string Name, string Driver)>.Empty;

private Scheduler scheduler => thread.Scheduler;

Expand Down Expand Up @@ -335,7 +335,7 @@
string deviceName = AudioDevice.Value;

// try using the specified device
int deviceIndex = audioDeviceNames.FindIndex(d => d == deviceName);
int deviceIndex = audioDeviceNames.FindIndex(d => d.Name == deviceName);
if (deviceIndex >= 0 && trySetDevice(BASS_INTERNAL_DEVICE_COUNT + deviceIndex)) return;

// try using the system default if there is any device present.
Expand Down Expand Up @@ -459,7 +459,10 @@
Trace.Assert(audioDevices.Length >= BASS_INTERNAL_DEVICE_COUNT, "Bass did not provide any audio devices.");

var oldDeviceNames = audioDeviceNames;
var newDeviceNames = audioDeviceNames = audioDevices.Skip(BASS_INTERNAL_DEVICE_COUNT).Where(d => d.IsEnabled).Select(d => d.Name).ToImmutableList();
var newDeviceNames = audioDeviceNames = audioDevices.Skip(BASS_INTERNAL_DEVICE_COUNT)
.Where(d => d.IsEnabled)

Check warning

Code scanning / InspectCode

Incorrect indent: Incorrect indent size Warning

Indent size is incorrect, expected indent 52 spaces
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
.Select(d => (d.Name, d.Driver))
.ToImmutableList();

scheduler.Add(() =>
{
Expand All @@ -477,9 +480,9 @@
{
eventScheduler.Add(delegate
{
foreach (string d in newDevices)
foreach (string d in newDevices.Select(d => d.Name))
OnNewDevice?.Invoke(d);
foreach (string d in lostDevices)
foreach (string d in lostDevices.Select(d => d.Name))
OnLostDevice?.Invoke(d);
});
}
Expand Down
Loading