Skip to content

Commit

Permalink
fix(MMNotification): Fix getting the current state of Default device …
Browse files Browse the repository at this point in the history
…at application startup. No more crash when there isn't a communication device set.

Fixes #1200
  • Loading branch information
Belphemur committed Jun 8, 2023
1 parent da55db0 commit e97330e
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -9,6 +9,7 @@
using Job.Scheduler.Job.Exception;
using Serilog;
using SoundSwitch.Audio.Manager;
using SoundSwitch.Audio.Manager.Interop.Enum;
using SoundSwitch.Common.Framework.Audio.Device;
using SoundSwitch.Framework.Threading;
using SoundSwitch.Model;
Expand Down Expand Up @@ -115,8 +116,12 @@ public void Register()
{
foreach (var role in Enum.GetValues<Role>().Where(role => role != Role.EnumCount))
{
var device = _mmDeviceEnumerator.GetDefaultAudioEndpoint(flow, role);
_lastRoleDevice[new DeviceRole(flow, role)] = device.ID;
var device = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow)flow, (ERole)role);
if (device == null)
{
continue;
}
_lastRoleDevice[new DeviceRole(flow, role)] = device.Id;
}
}
}
Expand Down

0 comments on commit e97330e

Please sign in to comment.