Determine which application is using audio device

廉价感情. 提交于 2021-02-08 04:01:19

问题


I'm currently using CoreAudio in macOS to determine if a specific audio input device is in use. I'm trying to find a little more information about what's going on with that device if it is in use, but struggling to find any information on how to do this.

1) Is it possible to find the application that is currently using a specific audio input device?

2) Is it possible to determine if an application is using an audio device (input or output) and has the device currently muted in that specific application?

Thanks


回答1:


If the application has hogged the device (i.e. has exclusive access to it) via kAudioDevicePropertyHogMode, then the value of the pid_t associated to that property is the process id of the hogging process (or -1 if the device isn't hogged.)

Otherwise, at least for output devices, multiple applications can share the device and the various audio streams are mixed. In that case the best you can do (that I know of) is to check kAudioDevicePropertyDeviceIsRunningSomewhere which will tell you if the device is in use, but not which process(es) is/are using it.

For question 2, mute is a property of the audio device, specifically kAudioDevicePropertyMute. If any application sets that property to true, then the device will be muted for all applications.



来源:https://stackoverflow.com/questions/41004926/determine-which-application-is-using-audio-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!