Sets the preferred input port for audio routing.
SDKs
- iOS 7.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- AVFoundation
Declaration
func setPreferredInput(_ inPort: AVAudio Session Port Description?) throws
Parameters
inPort
An
AVAudio
object describing the port to use for input.Session Port Description
Return Value
true
if a request was successfully made, or false
otherwise.
Discussion
Setting the preferred input port requests a change to the input audio route. To determine whether the change takes effect, use the current
property.
The value of the in
parameter must be one of the AVAudio
objects in the available
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.