Class

AVAudioSessionPortDescription

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

Declaration

class AVAudioSessionPortDescription : NSObject

Overview

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 query the audio session’s currentRoute property to get information about the active set of input and output ports. To change the current audio routing, call the setPreferredInput(_:) method. 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.

Topics

Getting the Port Attributes

var portName: String

A descriptive name for the port.

struct AVAudioSession.Port

A structure that defines the available input and output port types.

var channels: [AVAudioSessionChannelDescription]?

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

class AVAudioSessionChannelDescription

A class that describes a hardware channel on the current device.

var uid: String

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

var hasHardwareVoiceCallProcessing: Bool

A Boolean value that indicates whether 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.

Constants

Input Port Types

These values represent the port types available for audio input.

Output Port Types

These values represent the port types available for audio output.

I/O Port Types

These values represent the port types available for either audio input or output.

Relationships

Inherits From

Conforms To

See Also

Working with Audio Routes

var currentRoute: AVAudioSessionRouteDescription

A description of the current audio route’s input and output ports.

class AVAudioSessionRouteDescription

An object that describes the input and output ports associated with a session’s audio route.

var isInputAvailable: Bool

A Boolean value that indicates whether an audio input path is available.

var availableInputs: [AVAudioSessionPortDescription]?

An array of input ports available for audio routing.

var preferredInput: AVAudioSessionPortDescription?

The preferred input port for audio routing.

func setPreferredInput(AVAudioSessionPortDescription?)

Sets the preferred input port for audio routing.

var inputDataSource: AVAudioSessionDataSourceDescription?

The currently selected input data source.

var inputDataSources: [AVAudioSessionDataSourceDescription]?

An array of available data sources for the audio session’s current input port.

func setInputDataSource(AVAudioSessionDataSourceDescription?)

Selects a data source for the audio session’s current input port.

var outputDataSources: [AVAudioSessionDataSourceDescription]?

An array of available output data sources for the current audio route.

var outputDataSource: AVAudioSessionDataSourceDescription?

The currently selected output data source.

func setOutputDataSource(AVAudioSessionDataSourceDescription?)

Sets the output data source for an audio session.

class AVAudioSessionDataSourceDescription

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

func overrideOutputAudioPort(AVAudioSession.PortOverride)

Temporarily changes the current audio route.