Use audio display name if available

This commit is contained in:
dlprows 2023-10-04 00:17:41 -06:00
parent 4ca0ad021f
commit 6aaa32cf92
2 changed files with 16 additions and 5 deletions

View File

@ -68,7 +68,14 @@ public class AudioHelper
{ {
bestProcessMatch = audioProcess; bestProcessMatch = audioProcess;
currentIndex = index; currentIndex = index;
if(string.IsNullOrEmpty(results.DisplayName))
{
session.GetDisplayName(out var displayName);
results.DisplayName = displayName;
} }
}
//some apps like discord have multiple volume processes. //some apps like discord have multiple volume processes.
//and some apps will be on multiple devices //and some apps will be on multiple devices

View File

@ -26,10 +26,13 @@ public class NameAndIconHelper
var appx = AppxPackage.FromProcess(process); var appx = AppxPackage.FromProcess(process);
if (appx == null) if (appx == null)
{ {
//usingg process.MainModule.FileVersionInfo sometimes throws permission exceptions //using process.MainModule.FileVersionInfo sometimes throws permission exceptions
//we get the file version info with a limited query flag to avoid that //we get the file version info with a limited query flag to avoid that
var fileVersionInfo = GetFileVersionInfo(process); var fileVersionInfo = GetFileVersionInfo(process);
//if the display name is already set, then it came from the display name of the audio session
if (string.IsNullOrEmpty(results.DisplayName))
{
results.DisplayName = process.MainWindowTitle; results.DisplayName = process.MainWindowTitle;
if (string.IsNullOrEmpty(results.DisplayName)) if (string.IsNullOrEmpty(results.DisplayName))
@ -40,6 +43,7 @@ public class NameAndIconHelper
results.DisplayName = process.ProcessName; results.DisplayName = process.ProcessName;
} }
} }
}
results.ExecutablePath = fileVersionInfo?.FileName; results.ExecutablePath = fileVersionInfo?.FileName;
} }