Jeff
Jeff

Reputation: 520

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?

Upvotes: 0

Views: 893

Answers (1)

Tim
Tim

Reputation: 4813

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.

Upvotes: 3

Related Questions