Sets the preferred audio data source for the port.
SDKs
- iOS 7.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- AVFoundation
Declaration
func setPreferredDataSource(_ dataSource: AVAudio Session Data Source Description?) throws
Parameters
dataSource
The data source to be used.
Return Value
true
if a request was successfully made, or false
otherwise.
Discussion
Requests a change of data source; to determine whether the change takes effect, use the selected
property. (See “Configuring the Audio Session” in the AVAudio
class reference for details.)
If the port is in use, changing this setting will likely result in a route reconfiguration.
Set a preferred data source only after setting the audio session’s category and mode and activating the session.