pro100andrey / lame

Swift Lame Framework
MIT License
35 stars 7 forks source link

Type cast #1

Closed JqyModi closed 4 years ago

JqyModi commented 4 years ago

How do I turn Swift or OC objects into C arrays (char * argv[]), for example UnsafePointer to UnsafePointer<UnsafeMutablePointer?>?

pro100andrey commented 4 years ago

@JqyModi, hello, could you provide code example or additional info?

JqyModi commented 4 years ago

DemoURL:https://github.com/JqyModi/Swift_Sox I plan to use sox to process audio files, but I don't know how to convert the objects obtained by Swift into the array pointer received by C, the code is located in the SRC folder, I have the place of the comment, comment: // how to convert sourceRead to UnsafePointer<unsafemutablepointer?>?

JqyModi commented 4 years ago

@pro100andrey

pro100andrey commented 4 years ago

@JqyModi

Like this:

let argv = UnsafePointer(sourceRead.withMemoryRebound(to: Int8.self, capacity: MemoryLayout<sox_format_t>.size) { $0 })