ignore explorer process
This commit is contained in:
parent
6aaa32cf92
commit
d1df235af0
@ -1,12 +1,8 @@
|
|||||||
using BarRaider.SdTools;
|
using FocusVolumeControl.AudioSessions;
|
||||||
using FocusVolumeControl.AudioSessions;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FocusVolumeControl.AudioHelpers;
|
namespace FocusVolumeControl.AudioHelpers;
|
||||||
|
|
||||||
@ -27,6 +23,18 @@ public class AudioHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Process GetProcessById(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Process.GetProcessById(id);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IAudioSession FindSession(List<Process> processes)
|
public IAudioSession FindSession(List<Process> processes)
|
||||||
{
|
{
|
||||||
var results = new ActiveAudioSessionWrapper();
|
var results = new ActiveAudioSessionWrapper();
|
||||||
@ -55,7 +63,12 @@ public class AudioHelper
|
|||||||
sessionEnumerator.GetSession(i, out var session);
|
sessionEnumerator.GetSession(i, out var session);
|
||||||
|
|
||||||
session.GetProcessId(out var sessionProcessId);
|
session.GetProcessId(out var sessionProcessId);
|
||||||
var audioProcess = Process.GetProcessById(sessionProcessId);
|
var audioProcess = GetProcessById(sessionProcessId);
|
||||||
|
|
||||||
|
if(audioProcess == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var index = processes.FindIndex(x => x.Id == sessionProcessId || x.ProcessName == audioProcess?.ProcessName);
|
var index = processes.FindIndex(x => x.Id == sessionProcessId || x.ProcessName == audioProcess?.ProcessName);
|
||||||
|
|
||||||
@ -99,7 +112,7 @@ public class AudioHelper
|
|||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
var processes = GetPossibleProcesses();
|
var processes = GetPossibleProcesses();
|
||||||
var processIds = processes.Select(x => x.Id).ToArray();
|
var processIds = processes?.Select(x => x.Id).ToArray();
|
||||||
|
|
||||||
if (_currentProcesses == null || !_currentProcesses.SequenceEqual(processIds))
|
if (_currentProcesses == null || !_currentProcesses.SequenceEqual(processIds))
|
||||||
{
|
{
|
||||||
@ -145,7 +158,7 @@ public class AudioHelper
|
|||||||
|
|
||||||
if (handle == IntPtr.Zero)
|
if (handle == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
return null;
|
return new List<Process>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = Native.GetProcessesOfChildWindows(handle);
|
var ids = Native.GetProcessesOfChildWindows(handle);
|
||||||
@ -157,6 +170,11 @@ public class AudioHelper
|
|||||||
.Select(x => Process.GetProcessById(x))
|
.Select(x => Process.GetProcessById(x))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
if(processes.FirstOrDefault()?.ProcessName == "explorer")
|
||||||
|
{
|
||||||
|
return new List<Process>();
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//note. in instances where you launch a game from steam. this ends up mapping the process to both steam and to the game. which is unfortunate
|
//note. in instances where you launch a game from steam. this ends up mapping the process to both steam and to the game. which is unfortunate
|
||||||
|
Loading…
Reference in New Issue
Block a user