2017-08-16 12 views
1

osx内のすべてのアクティブな入力デバイスを照会してから、Bluetoothデバイス(接続されている場合)経由でオーディオを再生するためにAudioUnitを使用しようとしています。OSX CoreAudioのBluetoothデバイスメーカーのクエリがNULLを返す - 私はこのデバイスをAudioComponentFindNextのために参照する方法はありますか?

UIDとデバイス名を返すBluetoothデバイスがありますが、はデバイスメーカー(kAudioObjectPropertyManufacturer)を返すことができません。

アップルのドキュメントを読んで私はThe unique vendor identifier, registered with Apple, for the audio componentを参照しているので、ベンダーはアップルに登録することを嫌っていたはずです。

メーカーの指定なしデバイスの選択方法がわかりません。私は継承されたコードは次のようにオーディオを有効にします。デバイスの製造元なしAudioUnitを作成する方法は

AudioComponentDescription desc; 
desc.componentType = kAudioUnitType_Output; 
desc.componentSubType = kAudioUnitSubType_VoiceProcessingIO; // 'vpio' 
desc.componentManufacturer = manufacturerName; 
desc.componentFlags = 0; 
desc.componentFlagsMask = 0; 

AudioComponent comp = AudioComponentFindNext(NULL, &desc); 
OSStatus error = AudioComponentInstanceNew(comp, &myAudioUnit); 

ありますか?それとも、現在の入出力オーディオデバイスが設定されているものを使用してAudioUnitを作成する方法はありますか?

// deviceUID is a CFStringRef 

AudioDeviceID deviceID = kAudioDeviceUnknown; 

AudioObjectPropertyAddress propertyAddress = { 
    .mSelector = kAudioHardwarePropertyDeviceForUID, 
    .mScope  = kAudioObjectPropertyScopeGlobal, 
    .mElement = kAudioObjectPropertyElementMaster 
}; 

AudioValueTranslation translation = { 
    &deviceUID, sizeof(deviceUID), 
    &deviceID, sizeof(deviceID) 
}; 

UInt32 specifierSize = sizeof(translation); 

auto result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, nullptr, &specifierSize, &translation); 
if(kAudioHardwareNoError != result) { 
    // Handle error 
} 

if(kAudioDeviceUnknown == deviceID) 
    // The device isn't connected or doesn't exist 

をし、そこから、あなたはdeviceIDとAUのkAudioOutputUnitProperty_CurrentDeviceを設定することができます:あなたは、デバイスのUIDを持っている場合は

答えて

1

あなたは、デバイスIDに翻訳することができます。

関連する問題