improve sound browser debuggability by making it capture the window earlier so you can set a breakpoint and not have it just get VS info put in code to try to handle helldivers 2
45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace FocusVolumeControl.AudioSessions;
|
|
|
|
internal sealed class SystemVolumeAudioSession : IAudioSession
|
|
{
|
|
public SystemVolumeAudioSession(IAudioEndpointVolume volumeControl)
|
|
{
|
|
_volumeControl = volumeControl;
|
|
}
|
|
|
|
IAudioEndpointVolume _volumeControl;
|
|
|
|
public string DisplayName => "System Volume";
|
|
public string GetIcon() => "Images/encoderIcon";
|
|
|
|
public IEnumerable<int> Pids => new int[0];
|
|
|
|
public void ToggleMute()
|
|
{
|
|
_volumeControl.SetMute(!IsMuted(), Guid.Empty);
|
|
}
|
|
|
|
public bool IsMuted()
|
|
{
|
|
_volumeControl.GetMute(out var mute);
|
|
return mute;
|
|
}
|
|
|
|
public void IncrementVolumeLevel(int step, int ticks)
|
|
{
|
|
_volumeControl.GetMasterVolumeLevelScalar(out var level);
|
|
level = VolumeHelpers.GetAdjustedVolume(level, step, ticks);
|
|
_volumeControl.SetMasterVolumeLevelScalar(level, Guid.Empty);
|
|
}
|
|
|
|
public int GetVolumeLevel()
|
|
{
|
|
_volumeControl.GetMasterVolumeLevelScalar(out var level);
|
|
return VolumeHelpers.GetVolumePercentage(level);
|
|
}
|
|
}
|