AVAudioSession.Orientation has no constants defined in Swift. If one is given an AVAudioSession.Location value, how do we compare it against a value of type AVAudioSession.Orientation?
Specifically, I have found the following works, but I am not sure it's a reliable and correct way to compare and if it will work always on all iOS versions.
var preferredDataSource:AVAudioSessionDataSourceDescription?
let preferredMicrophoneLocation = AVAudioSession.Location.orientationFront
if let dataSources = builtinMicPort.dataSources {
for source in dataSources
{
if source.orientation?.rawValue == preferredMicrophoneLocation.rawValue
preferredDataSource = source
break
}
} // end data source iteration
}
}