0 Replies
      Latest reply on Jul 27, 2016 11:47 PM by theanalogkid
      theanalogkid Apple Staff Apple Staff (610 points)

        Using the kAudioOutputUnitProperty_CurrentDevice property with the Apple Voice Processing I/O audio unit ( kAudioUnitSubType_VoiceProcessingIO ) on macOS can trip you up if you don't follow these guidelines:

         

        The kAudioOutputUnitProperty_CurrentDevice property allows you to select the audio device being used by the I/O unit.

         

        @constant      kAudioOutputUnitProperty_CurrentDevice

         

                                  Global Scope

                                  Value Type: AudioObjectID

                                  Access: read/write

         

        When using the this property to select an audio device used by the Voice Processing I/O unit on macOS, the following guidelines should be observed:

         

        A) Both input and output busses must be enabled.

        B) The property must be set before initializing the audio unit.

        C) The property must be set on global scope ( kAudioUnitScope_Global ).

        D) You must set the desired input device by setting this property on the input element/bus.

         

        AudioUnitSetProperty(theVoiceIO, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 1, &deviceID, sizeof(AudioDeviceID));

         

            You must set the desired output device by setting the property on the output element/bus.

         

        AudioUnitSetProperty(theVoiceIO, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceID, sizeof(AudioDeviceID));

         

        E) Both input and output devices must be aggregatable, i.e. the device cannot be an aggregated device. A check is also performed for ( safety offset + presentation latency > maximum buffer frame size ) of the other device both ways.

        F) Setting both the input and output device simultaneously is recommended. Setting the property for one bus and not the other may fail if either the input or output device is not aggregatable. Explicitly setting both makes you aware if the devices can be aggregated.

         

            Error -10849 kAudioUnitErr_Initialized is returned if condition B has not been met.

            Error -10851 kAudioUnitErr_InvalidPropertyValue is returned if the device is an aggregate device, condition E.

            Error -10875 kAudioUnitErr_FailedInitialization may be returned if condition F has occurred.