Create a copy of CMSampleBuffer in Swift 2.0

微笑、不失礼 提交于 2019-12-04 08:42:59

Literally you're attempting to use the variable bufferCopy before it is initialized.

You've declared a type for it, but haven't allocated the memory it's pointing to.

You should instead create CMSampleBuffers using the following call https://developer.apple.com/library/tvos/documentation/CoreMedia/Reference/CMSampleBuffer/index.html#//apple_ref/c/func/CMSampleBufferCreate

You should be able to copy the buffer into this then (as long as the format of the buffer matches the one you're copying from).

You can simply pass a CMSampleBuffer? variable (which, as an optional, is implicitly initialized with nil) as inout argument with &:

var bufferCopy : CMSampleBuffer?
let err = CMSampleBufferCreateCopy(kCFAllocatorDefault, buffer, &bufferCopy)
if err == noErr {
    // ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!