Information about the capabilities of the port and the hardware channels it supports.


class AVAudioSessionPortDescription : NSObject


A port description object describes a single input or output port associated with an audio route.

Examples of audio ports include a device’s built-in speaker, a microphone on a wired headset, and a Bluetooth device supporting the Advanced Audio Distribution Profile (A2DP).

You can use port descriptions with the shared AVAudioSession object:

For example, on a device with a wired headset attached, the audio session’s availableInputs array may contain two port descriptions: one for the headset microphone and one for the device’s built-in microphone. You can use the audio session’s setPreferredInput(_:) method to select the headset or built-in microphone for audio input.


Getting the Port Attributes

var portName: String

A descriptive name for the port.

var channels: [AVAudioSessionChannelDescription]?

An array of channel objects that describe the port’s input or output channels.

var uid: String

A system-assigned unique identifier (UID) for the port.

var hasHardwareVoiceCallProcessing: Bool

Indicates if the associated hardware port has built-in processing for two-way voice communication.

Managing a Port’s Data Sources

var dataSources: [AVAudioSessionDataSourceDescription]?

The available data sources for the port.

var selectedDataSource: AVAudioSessionDataSourceDescription?

The currently selected audio data source for the port.

var preferredDataSource: AVAudioSessionDataSourceDescription?

The preferred audio data source for the port.

func setPreferredDataSource(AVAudioSessionDataSourceDescription?)

Sets the preferred audio data source for the port.


Input Port Types

Port types used for audio input.

Output Port Types

Port types used for audio output.

I/O Port Types

Port types that can be used for either audio input or output.


Inherits From

Conforms To

See Also

Supporting Types

class AVAudioSessionChannelDescription

A channel description provides descriptive information about a hardware channel on the current device.

class AVAudioSessionDataSourceDescription

A description that defines a data source for an audio input or output, giving information such as the source’s name, location and orientation.

class AVAudioSessionRouteDescription

A route description manages the input and output ports associated with the current audio route for a session.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software