I have a function in C that takes a pointer. I am trying to call it from Swift.
From Calling C function from Swift, (and personal experience), doing &var does not work.
However, I am not able to cast &var into UnsafeMutablePointer... nor any type of conversion (like assigning the address of var to another variable of type UnsafeMutablePointer)
(assume Type is an object)
Thanks
Sample code:
var zero = CreateCompressionSession(&session as UnsafeMutablePointer<Unmanaged<VTCompressionSession>?>, Int32(CVPixelBufferGetWidth(pixelBuffer)), Int32(CVPixelBufferGetHeight(pixelBuffer)))
while trying to get it to call:
int CreateCompressionSession(VTCompressionSessionRef* session, int width, int height) {
OSStatus err = VTCompressionSessionCreate(NULL, width, height, kCMVideoCodecType_H264, NULL, NULL, NULL, (VTCompressionOutputCallback)vtCallback, NULL, session);
NSLog(@"%d %p", (int)err, session);
if (err == noErr) {
return 0;
} else {
return err;
}
}