Skip to content

Commit

Permalink
It's possible the list of device is uninitialised
Browse files Browse the repository at this point in the history
Fixes #481
  • Loading branch information
Belphemur committed Jul 26, 2020
1 parent 8781a69 commit ec26022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public class TooltipInfoPlayback : ITooltipInfo
/// <returns></returns>
public string TextToDisplay()
{
var audioDevices = AppModel.Instance.ActiveAudioDeviceLister.PlaybackDevices;
var audioDevices = AppModel.Instance.ActiveAudioDeviceLister?.PlaybackDevices;
if (audioDevices == null)
{
return string.Format(SettingsStrings.activePlayback, "Unknown");
}

var playbackDefaultDevice = audioDevices
.FirstOrDefault(device =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ namespace SoundSwitch.Framework.TrayIcon.TooltipInfoManager.TootipInfo
public class TooltipInfoRecording : ITooltipInfo
{
public TooltipInfoTypeEnum TypeEnum => TooltipInfoTypeEnum.Recording;
public string Label => SettingsStrings.tooltipOnHoverOptionRecordingDevice;
public string Label => SettingsStrings.tooltipOnHoverOptionRecordingDevice;

/// <summary>
/// The text to display for this ToolTip
/// </summary>
/// <returns></returns>
public string TextToDisplay()
{
var recordingDevice = AppModel.Instance.ActiveAudioDeviceLister.RecordingDevices.FirstOrDefault(device =>
AudioSwitcher.Instance.IsDefault(device.Id, (EDataFlow)device.Type, ERole.eConsole));
var recordingDevices = AppModel.Instance.ActiveAudioDeviceLister?.RecordingDevices;
if (recordingDevices == null)
{
return string.Format(SettingsStrings.activeRecording, "Unknown");
}

var recordingDevice = recordingDevices?.FirstOrDefault(device =>
AudioSwitcher.Instance.IsDefault(device.Id, (EDataFlow) device.Type, ERole.eConsole));
return recordingDevice == null ? null : string.Format(SettingsStrings.activeRecording, recordingDevice);
}

Expand Down

0 comments on commit ec26022

Please sign in to comment.