File tree 1 file changed +8
-6
lines changed
SoundSwitch/Framework/Audio/Microphone
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -16,29 +16,31 @@ public MicrophoneMuteToggler(AudioSwitcher switcher)
16
16
17
17
/// <summary>
18
18
/// Toggle mute state for the default microphone
19
+ /// <returns>The current mute state, null if couldn't interact with the microphone</returns>
19
20
/// </summary>
20
- public bool ToggleDefaultMute ( )
21
+ public bool ? ToggleDefaultMute ( )
21
22
{
22
23
var microphone = _switcher . GetDefaultMmDevice ( EDataFlow . eCapture , ERole . eCommunications ) ;
23
24
if ( microphone == null )
24
25
{
25
26
Log . Information ( "Couldn't find a default microphone to toggle mute" ) ;
26
- return false ;
27
+ return null ;
27
28
}
28
29
29
- return _switcher . InteractWithMmDevice ( microphone , device =>
30
+ return _switcher . InteractWithMmDevice < bool ? > ( microphone , device =>
30
31
{
31
32
try
32
33
{
33
- device . AudioEndpointVolume . Mute = ! microphone . AudioEndpointVolume . Mute ;
34
- return true ;
34
+ var newMuteState = ! microphone . AudioEndpointVolume . Mute ;
35
+ device . AudioEndpointVolume . Mute = newMuteState ;
36
+ return newMuteState ;
35
37
}
36
38
catch ( Exception e )
37
39
{
38
40
Log . Error ( "Couldn't toggle mute on {device}:\n {exception}" , microphone . FriendlyName , e ) ;
39
41
}
40
42
41
- return false ;
43
+ return null ;
42
44
} ) ;
43
45
}
44
46
}
You can’t perform that action at this time.
0 commit comments