简体   繁体   中英

Check if audio input devices are in use (macOS) (Swift)

I'm using AVFoundation to get a list of audio capture devices on a system, and I'd like to determine if any application on the system is currently capturing audio from this device or has the device in use.

I saw there is a isInUseByAnotherApplication value for AVCaptureDevice, but it looks like that flag is only there if another application has an exclusive lock on that device.

Is it possible to determine if an application is currently capturing audio from an AVCaptureDevice on OS X?

You need to drop down to the lower-level CoreAudio APIs.

Checkout the property kAudioDevicePropertyDeviceIsRunningSomewhere in AudioHardware.h . You can query this property on both input and output devices and it should give you the info you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM