Skip to content

Commit

Permalink
modifed inline function to account for main PID
Browse files Browse the repository at this point in the history
  • Loading branch information
nefares committed Apr 27, 2023
1 parent 545a342 commit fcafd28
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions WinBGMute/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,14 @@ private void RunMuter(int fpid, bool doMute = true)


//Inline function to mute/unmute a list of processes
Func<Process[], bool, string> InlineMuteProcList = (procs, isMuted) =>
Func<Process[], bool, int?, string> InlineMuteProcList = (procs, isMuted, additionalPID) =>
{
string log_output = "";

if (additionalPID != null)
{
m_volumeMixer.SetApplicationMute((int)additionalPID, isMuted);
}
foreach (var fproc_similar in procs)
{
var fproc_similar_pid = fproc_similar.Id;
Expand All @@ -237,7 +242,7 @@ private void RunMuter(int fpid, bool doMute = true)
// if yes unmute all foreground processes with the same name
if (audio_pname == fname)
{
string log_output = InlineMuteProcList(audio_proc_list, false);
string log_output = InlineMuteProcList(audio_proc_list, false, audio_pid);
LoggingEngine.LogLine($"[+] Unmuting foreground process {audio_pname}({audio_pid}) {log_output} ", Color.BlueViolet);
}
// mute all other processes (with an audio channel), except the ones on the neverMuteList
Expand All @@ -259,19 +264,19 @@ private void RunMuter(int fpid, bool doMute = true)
if (!IsIconic(handle))
{
// if minimize option AND NOT minimized: SKIP
InlineMuteProcList(audio_proc_list, false);
InlineMuteProcList(audio_proc_list, false, audio_pid);
log_skipped += "[M]" + audio_pname + ", ";
}
else
{
InlineMuteProcList(audio_proc_list, true);
InlineMuteProcList(audio_proc_list, true, audio_pid);
log_muted += audio_pname + ", ";
}
}
else
{
//if mute condition is background and not on mute list
InlineMuteProcList(audio_proc_list, true);
InlineMuteProcList(audio_proc_list, true, audio_pid);
log_muted += audio_pname + ", ";
}
}
Expand Down

0 comments on commit fcafd28

Please sign in to comment.