OSX:使用Core Audio检测是否通过扬声器播放音频

时间:2015-11-26 01:51:38

标签: macos core-audio

我正在学习如何构建OSX应用程序,我想知道是否有办法检查系统上的任何应用程序是否输出了某些音频?感谢

2 个答案:

答案 0 :(得分:0)

这不能在用户应用程序级别完成。可以通过安装OS X kext(内核扩展)或自定义音频设备驱动程序来实现,这需要sudo权限并可能需要重新启动。

答案 1 :(得分:0)

我认为可以使用example.com/Situations/1属性进行检查。

来自标题文档:

kAudioDevicePropertyDeviceIsRunningSomewhere

伪码:

A UInt32 where 1 means that the AudioDevice is running in at least one process on the system and 0 means that it isn't running at all.

这应告诉您设备是否正在使用(即有效bool isRunningSomewhere(AudioDeviceID deviceId) { uint32 val; uint32 size = sizeof(val); AudioObjectPropertyAddress pa = { kAudioDevicePropertyDeviceIsRunningSomewhere, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectGetPropertyData(deviceId, &pa, 0, NULL, &size, &val); return val == 1; } 。)但它不会告诉您IOProc是否只是发送静音。

相关问题