improved mic 'inactive' alerts

fix for #36
This commit is contained in:
Patrick Wardle 2022-11-21 19:41:28 -10:00
parent 4425d1df0f
commit 998ecf2b5b
2 changed files with 11 additions and 13 deletions

View File

@ -910,7 +910,7 @@ bail:
} }
//check if a specified video is active //check if a specified video is active
// note: on M1 this always says 'on' (smh apple) // note: on M1 this sometimes always says 'on' (smh apple)
-(UInt32)getCameraState:(AVCaptureDevice*)device -(UInt32)getCameraState:(AVCaptureDevice*)device
{ {
//status var //status var
@ -1061,7 +1061,7 @@ bail:
// need extra logic, since macOS sometimes toggles / delivers 2x events :/ // need extra logic, since macOS sometimes toggles / delivers 2x events :/
if(Device_Microphone == event.deviceType) if(Device_Microphone == event.deviceType)
{ {
//ignore if device's last event was <0.5 //ignore if mic's last event was <0.5
if([event.timestamp timeIntervalSinceDate:deviceLastEvent.timestamp] < 0.5f) if([event.timestamp timeIntervalSinceDate:deviceLastEvent.timestamp] < 0.5f)
{ {
//set result //set result
@ -1074,15 +1074,14 @@ bail:
goto bail; goto bail;
} }
//ignore if device's last event was same state //ignore if mic's last event was same state
if( (deviceLastEvent.state == event.state) && if(deviceLastEvent.state == event.state)
([event.timestamp timeIntervalSinceDate:deviceLastEvent.timestamp] < 2.0f) )
{ {
//set result //set result
result = NOTIFICATION_SPURIOUS; result = NOTIFICATION_SPURIOUS;
//dbg msg //dbg msg
os_log_debug(logHandle, "ignoring mic event, as it happened <1.0 and is same state (%ld)", (long)event.state); os_log_debug(logHandle, "ignoring mic event as it was same state as last (%ld)", (long)event.state);
//bail //bail
goto bail; goto bail;
@ -1117,6 +1116,9 @@ bail:
bail: bail:
//(always) update last event
self.deviceEvents[deviceID] = event;
return result; return result;
} }
@ -1134,6 +1136,7 @@ bail:
result = [self shouldShowNotification:event]; result = [self shouldShowNotification:event];
} }
//deliver/show user?
if(NOTIFICATION_DELIVER == result) if(NOTIFICATION_DELIVER == result)
{ {
//deliver //deliver

View File

@ -32,13 +32,8 @@
//init color //init color
selectionColor = [NSColor systemGrayColor]; selectionColor = [NSColor systemGrayColor];
//on 10.14+
//set to transparent //set to transparent
if (@available(macOS 10.14, *)) {
//set color
selectionColor = [NSColor unemphasizedSelectedContentBackgroundColor]; selectionColor = [NSColor unemphasizedSelectedContentBackgroundColor];
}
//set stroke //set stroke
[selectionColor setStroke]; [selectionColor setStroke];