How to detect microphone usage on OS X?

前端 未结 4 768
梦如初夏
梦如初夏 2021-01-18 04:11

Is there a way to detect when the microphone of my Mac is in use? Similar to what Mikro Snitch does? Can this be done in Cocoa?

4条回答
  •  一向
    一向 (楼主)
    2021-01-18 05:02

    I'm working on go module that detects camera/microphone state (using cgo) and here is my crafted Objective-C implementation for IsMicrophoneOn(): https://github.com/antonfisher/go-media-devices-state/blob/main/pkg/microphone/microphone_darwin.mm

    I used kAudioHardwarePropertyDevices to get all audio devices (microphones + speakers) and then [AVCaptureDevice deviceWithUniqueID:uid] to filter out only microphones by device UID.

提交回复
热议问题