Skip to content

Commit

Permalink
use the first available audio device
Browse files Browse the repository at this point in the history
  • Loading branch information
krn1pnc committed Aug 6, 2024
1 parent b494994 commit eaba693
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion OpenUtau.Core/Audio/MiniAudioOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ public MiniAudioOutput() {
if (Guid.TryParse(Preferences.Default.PlaybackDevice, out var guid)) {
SelectDevice(guid, Preferences.Default.PlaybackDeviceNumber);
} else {
SelectDevice(devices[0].guid, devices[0].deviceNumber);
bool foundDevice = false;
foreach (AudioOutputDevice dev in devices) {
try {
SelectDevice(dev.guid, dev.deviceNumber);
foundDevice = true;
break;
} catch (Exception e) {
Log.Warning(e, $"Failed to init audio device {dev}");
}
}
if (!foundDevice) {
throw new Exception("Failed to init any audio device");
}
}
}

Expand Down

0 comments on commit eaba693

Please sign in to comment.