Class

AVAudioSessionPortDescription

A port description object describes a single input or output port associated with an audio route. You can use the information in this class to obtain information about the capabilities of the port and the hardware channels it supports.

Overview

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.

Topics

Getting the Port Attributes

var portName: String

A descriptive name for the port.

var portType: String

The type of 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.

Constants

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.

Relationships

Inherits From

Conforms To

See Also

Supporting Types

protocol AVAudioSessionDelegate

The use of this protocol is deprecated in iOS 6 and later. Instead, you should use the notifications declared in AVAudioSession.

class AVAudioSessionChannelDescription

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

class AVAudioSessionDataSourceDescription

A data source description defines a data source for an audio input or output, providing 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.