I came up with this solution. Don't know if it's safe or has any drawbacks compared to my Swift 2 solution...
let outBuffers = unsafeBitCast(UnsafeMutablePointer(mutating: bufPtrs), to: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>.self) let inBuffers = unsafeBitCast(frame?.pointee.extended_data, to: UnsafeMutablePointer<UnsafePointer<UInt8>?>.self) numSamplesDecoded = swr_convert(audioPlayer.swrContext!, outBuffers, (frame?.pointee.nb_samples)!, inBuffers, (frame?.pointee.nb_samples)!)
Any comments are welcome!
unsafeBitCast(_:to:)is generally a last resort mechanism. Hopefully we can do better.
Note Before going further I strongly recommend you read the UnsafeRawPointer Migration doc, which covers a lot of the backstory here.
What does the C prototype for
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
If the library routine really processes a data vector of floats (not bytes), then you might want to create a C wrapper function around that library routine that declares the correct vector types, and from Swift call your corrected C wrapper instead of the library routine directly.