Compare commits
No commits in common. "609a7bdb655c7cabb53ad44e8371eb13bde2f630" and "bbad79b4f38582a95521d78894fb69bf11c81429" have entirely different histories.
609a7bdb65
...
bbad79b4f3
@ -36,7 +36,6 @@ public class AudioHelper
|
||||
manager.GetSessionEnumerator(out var sessionEnumerator);
|
||||
|
||||
var results = new ActiveAudioSessionWrapper();
|
||||
var currentIndex = int.MaxValue;
|
||||
|
||||
sessionEnumerator.GetCount(out var count);
|
||||
for (int i = 0; i < count; i++)
|
||||
@ -46,14 +45,7 @@ public class AudioHelper
|
||||
session.GetProcessId(out var sessionProcessId);
|
||||
var audioProcess = Process.GetProcessById(sessionProcessId);
|
||||
|
||||
var index = processes.FindIndex(x => x.Id == sessionProcessId || x.ProcessName == audioProcess?.ProcessName);
|
||||
|
||||
if (index > -1)
|
||||
{
|
||||
//processes will be ordered from best to worst (starts with the app, goes to parent)
|
||||
//so we want the display name and executable path to come from the process that is closest to the front of the list
|
||||
//but we want all matching sessions so things like discord work right
|
||||
if (index < currentIndex)
|
||||
if (processes.Any(x => x.Id == sessionProcessId || x.ProcessName == audioProcess?.ProcessName))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -66,13 +58,10 @@ public class AudioHelper
|
||||
}
|
||||
catch
|
||||
{
|
||||
results.DisplayName = audioProcess.ProcessName;
|
||||
results.DisplayName ??= audioProcess.ProcessName;
|
||||
}
|
||||
|
||||
results.ExecutablePath = audioProcess.MainModule.FileName;
|
||||
|
||||
currentIndex = index;
|
||||
}
|
||||
results.ExecutablePath ??= audioProcess.MainModule.FileName;
|
||||
|
||||
//some apps like discord have multiple volume processes.
|
||||
results.AddSession(session);
|
||||
@ -154,15 +143,14 @@ public class AudioHelper
|
||||
//Additionally, I group all audio processes that match instead of just the most specific, or the first, etc. Because Discord uses two processes, one for voice chat, and one for discord sounds.
|
||||
//
|
||||
//Steam and Discord are both very common, and end up butting heads in the algorithm.
|
||||
//I want to avoid special cases, but since steam and discord are both so common, i'm making an exception.
|
||||
var parentProcess = ParentProcessUtilities.GetParentProcess(pid);
|
||||
if (parentProcess != null
|
||||
&& parentProcess.ProcessName != "explorer"
|
||||
&& parentProcess.ProcessName != "svchost"
|
||||
&& (parentProcess.ProcessName == "steam" && processes.Any(x => x.ProcessName == "steamwebhelper")) //only include steam if the parent process is the steamwebhelper
|
||||
)
|
||||
//And I'm not overly fond of programming in special cases
|
||||
//so for the time being, the only down side i've found for including the parent process is that when you launch a game from steam and change the volume, you also change steam's volume. but that really only impacts videos on steam store pages
|
||||
//The icon is also often steam's icon instead of the games'.
|
||||
//But i'm striving for functional before perfection.
|
||||
var blah = ParentProcessUtilities.GetParentProcess(pid);
|
||||
if (blah != null && blah.ProcessName != "explorer" && blah.ProcessName != "svchost")
|
||||
{
|
||||
processes.Add(parentProcess);
|
||||
processes.Add(blah);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
Loading…
Reference in New Issue
Block a user