我正在维护一组从AVCaptureSynchronizedData
. 我使用的一种方法修改了CVPixelBuffers
从AVCaptureSynchronizedData
. 修改时。,我创建了一个viaCVPixelBuffer
的副本CVPixelBuffer
let status = CVPixelBufferCreateWithBytes(nil, scaleWidth, scaleHeight,
pixelFormat, destData,
destBytesPerRow, releaseCallback,
nil, nil, &dstPixelBuffer)
被releaseCallBack
引用为
let releaseCallback: CVPixelBufferReleaseBytesCallback = { _, ptr in
if let ptr = ptr {
free(UnsafeMutableRawPointer(mutating: ptr))
}
}
但是,我希望能够跟上这被调用的次数。但是,如果我添加类似
var num:Int = 0
let releaseCallback: CVPixelBufferReleaseBytesCallback = { _, ptr in
if let ptr = ptr {
num += 1
free(UnsafeMutableRawPointer(mutating: ptr))
}
}
我得到错误
AC 函数指针不能由捕获上下文的闭包形成
不确定是否可能,但是能够计算指针被销毁的次数将非常有用