79084321

Date: 2024-10-13 22:56:26
Score: 0.5
Natty:
Report link

The issue here is that Objective-C allows nullable pointers, and Swift has strict typing around optional and non-optional pointers.

Since floatChannelData is of type UnsafePointer<UnsafeMutablePointer>, you can map it to the correct type using this conversion:

if let floatChannelData = buffer.floatChannelData {
    // Convert the pointer to the expected form
    let data = UnsafePointer<UnsafeMutablePointer<Float>?>(floatChannelData)
    
    audioProcess(Int32(buffer.format.channelCount),
                 numSamples: Int32(buffer.frameLength),
                 stride: Int32(buffer.stride),
                 data: data)
}

different UnsafePointer for Swift and Objective-C/C++

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Can