swiftavaudioengineavaudioplayernode

Get name or ID of current audio output using swift


My application allows the user to select which Audio Output device is being used to play sound. I can’t find or figure out how to get the current Audio Output device being used by the system.

Im using AVAudioEngine to play my audio. There’s no get property on the main mixer as i’d expect...


Solution

  • The output device isn't a property of the mixer, it's a property of the output node's audio unit.

    audioEngine.outputNode.auAudioUnit.deviceID
    

    will return the AUAudioObjectID of the hardware device used by the output unit. It isn't necessarily the output device used by the system.