How to detect microphone usage on OS X?

前端 未结 4 764
梦如初夏
梦如初夏 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 04:54

    This isn't really an Objective-C or Cocoa solution, but if you're willing to do a subprocess call, try this:

    ioreg -c AppleHDAEngineInput | grep IOAudioEngineState
    

    You will see "IOAudioEngineState" = 1 when audio input is active.

    Also, try searching for IOAudioEngineNumActiveUserClients which increases by one for each app taking in audio.

提交回复
热议问题