Instance Method

setPreferredInput:error:

Sets the preferred input port for audio routing.

Declaration

- (BOOL)setPreferredInput:(AVAudioSessionPortDescription *)inPort error:(NSError * _Nullable *)outError;

Parameters

inPort

An AVAudioSessionPortDescription object describing the port to use for input.

outError

On input, a pointer to an error object. If an error occurs, the pointer is set to an NSError object that describes the error. If you do not want error information, pass in nil.

Return Value

YES if a request was successfully made, or NO otherwise.

Discussion

Setting the preferred input port requests a change to the input audio route. To determine whether the change takes effect, use the currentRoute property.

The value of the inPort parameter must be one of the AVAudioSessionPortDescription objects in the availableInputs array. If this parameter specifies a port that is not already part of the current audio route and the app’s session controls audio routing, this method initiates a route change to use the preferred port.

You must set a preferred input port only after setting the audio session’s category and mode and activating the session.

See Also

Working with Audio Routes

currentRoute

An object describing the current audio input and output route.

inputAvailable

A Boolean value indicating whether an audio input path is available.

availableInputs

An array of input ports available for routing.

preferredInput

The preferred input port for audio routing.

inputDataSources

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

inputDataSource

The currently selected input data source.

- setInputDataSource:error:

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

outputDataSources

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

outputDataSource

The currently selected output data source.

- setOutputDataSource:error:

Sets the output data source for an audio session.

- overrideOutputAudioPort:error:

Temporarily changes the current audio route.

routeSharingPolicy

The current routing policy.

- setCategory:mode:routeSharingPolicy:options:error:

Sets the session category, mode, route sharing policy, and options.