Skip to content

Commit 2ef778b

Browse files
committed
feat(Profile::RecordingCommunication): Add possibility to set communication device for recording device in Profile.cs
Fixes #793
1 parent 7881f16 commit 2ef778b

File tree

6 files changed

+177
-43
lines changed

6 files changed

+177
-43
lines changed

SoundSwitch/Framework/Profile/Profile.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ internal DeviceRoleWrapper(DeviceInfo deviceInfo, ERole role)
3131
public DeviceInfo? Playback { get; set; }
3232
public DeviceInfo? Communication { get; set; }
3333
public DeviceInfo? Recording { get; set; }
34+
35+
public DeviceInfo? RecordingCommunication { get; set; }
3436

3537
public string Name { get; set; } = "";
3638
public IList<Trigger.Trigger> Triggers { get; set; } = new List<Trigger.Trigger>();
@@ -75,6 +77,7 @@ public Profile Copy()
7577
Name = Name,
7678
Playback = Playback,
7779
Recording = Recording,
80+
RecordingCommunication = RecordingCommunication,
7881
RestoreDevices = RestoreDevices,
7982
Triggers = Triggers.Select(trigger => new Trigger.Trigger(trigger.Type)
8083
{
@@ -96,7 +99,9 @@ internal IEnumerable<DeviceRoleWrapper> Devices
9699
if (Communication != null)
97100
yield return new DeviceRoleWrapper(Communication, ERole.eCommunications);
98101
if (Recording != null)
99-
yield return new DeviceRoleWrapper(Recording, ERole.ERole_enum_count);
102+
yield return new DeviceRoleWrapper(Recording, RecordingCommunication == null ? ERole.ERole_enum_count : ERole.eConsole | ERole.eMultimedia);
103+
if (RecordingCommunication != null)
104+
yield return new DeviceRoleWrapper(RecordingCommunication, ERole.eCommunications);
100105
}
101106
}
102107

SoundSwitch/Framework/Profile/ProfileManager.cs

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ private bool SaveCurrentState(User32.NativeMethods.HWND windowHandle, Profile pr
265265
var communication = _audioSwitcher.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eCommunications);
266266
var playback = _audioSwitcher.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
267267
var recording = _audioSwitcher.GetDefaultAudioEndpoint(EDataFlow.eCapture, ERole.eMultimedia);
268+
var recordingCommunication = _audioSwitcher.GetDefaultAudioEndpoint(EDataFlow.eCapture, ERole.eCommunications);
268269

269270
var currentState = new Profile
270271
{
@@ -273,6 +274,7 @@ private bool SaveCurrentState(User32.NativeMethods.HWND windowHandle, Profile pr
273274
Communication = communication,
274275
Playback = playback,
275276
Recording = recording,
277+
RecordingCommunication = recordingCommunication,
276278
NotifyOnActivation = profile.NotifyOnActivation
277279
};
278280
_activeWindowsTrigger.Add(windowHandle, currentState);

SoundSwitch/UI/Forms/Settings.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ ListViewItem ProfileToListViewItem(Profile profile)
225225
DeviceFullInfo recording = null;
226226
DeviceFullInfo playback = null;
227227
DeviceFullInfo communication = null;
228-
228+
DeviceFullInfo recordingCommunication = null;
229+
229230
var applicationTrigger = profile.Triggers.FirstOrDefault(trig => trig.Type == TriggerFactory.Enum.Process);
230231
var hotkeyTrigger = profile.Triggers.FirstOrDefault(trig => trig.Type == TriggerFactory.Enum.HotKey);
231232

@@ -258,6 +259,12 @@ ListViewItem ProfileToListViewItem(Profile profile)
258259
communication = _audioDeviceLister.PlaybackDevices.FirstOrDefault(info =>
259260
info.Equals(profile.Communication));
260261
}
262+
263+
if (profile.RecordingCommunication != null)
264+
{
265+
recordingCommunication = _audioDeviceLister.RecordingDevices.FirstOrDefault(info =>
266+
info.Equals(profile.RecordingCommunication));
267+
}
261268

262269
listViewItem.SubItems.AddRange(new[]
263270
{
@@ -270,6 +277,8 @@ ListViewItem ProfileToListViewItem(Profile profile)
270277
recording?.NameClean ?? profile.Recording?.ToString() ?? "") {Tag = recording?.SmallIcon},
271278
new ListViewItem.ListViewSubItem(listViewItem,
272279
communication?.NameClean ?? profile.Communication?.ToString() ?? "") {Tag = communication?.SmallIcon},
280+
new ListViewItem.ListViewSubItem(listViewItem,
281+
recordingCommunication?.NameClean ?? profile.RecordingCommunication?.ToString() ?? "") {Tag = recordingCommunication?.SmallIcon},
273282
});
274283

275284
return listViewItem;

0 commit comments

Comments
 (0)