Support for multiple audio devices. such as when using voicemeeter

improved display name and icon support
fixed issues with games like halo master chief collection, which threw exceptions when getting the display name
This commit is contained in:
2023-09-30 19:54:35 -06:00
parent 2b10b6d7a6
commit 4c1ccd9025
13 changed files with 602 additions and 182 deletions

View File

@@ -11,6 +11,7 @@ public sealed class ActiveAudioSessionWrapper : IAudioSession
{
public string DisplayName { get; set; }
public string ExecutablePath { get; set; }
public string IconPath { get; set; }
private List<IAudioSessionControl2> Sessions { get; } = new List<IAudioSessionControl2>();
private IEnumerable<ISimpleAudioVolume> Volume => Sessions.Cast<ISimpleAudioVolume>();
@@ -22,8 +23,17 @@ public sealed class ActiveAudioSessionWrapper : IAudioSession
{
try
{
var tmp = Icon.ExtractAssociatedIcon(ExecutablePath);
_icon = Tools.ImageToBase64(tmp.ToBitmap(), true);
if(!string.IsNullOrEmpty(IconPath))
{
var tmp = (Bitmap)Bitmap.FromFile(IconPath);
tmp.MakeTransparent();
_icon = Tools.ImageToBase64(tmp, true);
}
else
{
var tmp = Icon.ExtractAssociatedIcon(ExecutablePath);
_icon = Tools.ImageToBase64(tmp.ToBitmap(), true);
}
}
catch
{