0
我需要得到通知,當一個新的音頻設備出現在OS X上。我不知道從哪裏開始。 Core Audio可以爲我做這件事,還是我需要使用IO Kit來降低音量?OS X:響應新的音頻設備
我需要得到通知,當一個新的音頻設備出現在OS X上。我不知道從哪裏開始。 Core Audio可以爲我做這件事,還是我需要使用IO Kit來降低音量?OS X:響應新的音頻設備
您可以通過觀察kAudioHardwarePropertyDevices
來做到這一點。代碼看起來大致是:
AudioObjectPropertyAddress propertyAddress = {
.mSelector = kAudioHardwarePropertyDevices,
.mScope = kAudioObjectPropertyScopeGlobal,
.mElement = kAudioObjectPropertyElementMaster
};
OSStatus result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &propertyAddress, myAudioObjectPropertyListenerProc, NULL);
在myAudioObjectPropertyListenerProc
你可以決定哪些設備目前已經上市。