- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我需要调用 CMSampleBufferCreateCopy 函数来创建 sampleBuffer 的副本,但我真的不知道如何使用它。
根据 this solution它应该像这样工作:
var bufferCopy: Unmanaged<CMSampleBuffer>!
let error = CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &bufferCopy)
但事实并非如此。
我得到的错误信息:
Cannot invoke 'CMSampleBufferCreateCopy' with an argument list of type '(CFAllocator!, CMSampleBuffer!, inout Unmanaged<CMSampleBuffer>!)'
编辑:
@availability(iOS, introduced=4.0)
func CMSampleBufferCreateCopy(allocator: CFAllocator!, sbuf: CMSampleBuffer!, sbufCopyOut: UnsafeMutablePointer<Unmanaged<CMSampleBuffer>?>) -> OSStatus
/*! @param allocator
The allocator to use for allocating the CMSampleBuffer object.
Pass kCFAllocatorDefault to use the default allocator. */
/*! @param sbuf
CMSampleBuffer being copied. */
/*! @param sbufCopyOut
Returned newly created CMSampleBuffer. */
/*!
@function CMSampleBufferCreateCopyWithNewTiming
@abstract Creates a CMSampleBuffer with new timing information from another sample buffer.
@discussion This emulates CMSampleBufferCreateCopy, but changes the timing.
Array parameters (sampleTimingArray) should have only one element if that same
element applies to all samples. All parameters are copied; on return, the caller can release them,
free them, reuse them or whatever. Any outputPresentationTimestamp that has been set on the original Buffer
will not be copied because it is no longer relevant. On return, the caller owns the returned
CMSampleBuffer, and must release it when done with it.
*/
最佳答案
从最后一个参数的声明可以看出,
sbufCopyOut: UnsafeMutablePointer<Unmanaged<CMSampleBuffer>?>
bufferCopy
必须声明为可选,而不是隐式声明展开可选:
var bufferCopy: Unmanaged<CMSampleBuffer>?
请注意,您必须对结果调用 takeRetainedValue()
,所以完整的解决方案是:
var unmanagedBufferCopy: Unmanaged<CMSampleBuffer>?
if CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &unmanagedBufferCopy) == noErr {
let bufferCopy = unmanagedBufferCopy!.takeRetainedValue()
// ...
} else {
// failed
}
更新:在 Swift 4 中(可能已经在 Swift 4 中),CMSampleBufferCreateCopy()
返回一个托管对象,因此代码简化为
var bufferCopy: CMSampleBuffer?
if CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &bufferCopy) == noErr {
// ... use bufferCopy! ...
} else {
// failed
}
关于ios - Swift 中的 UnsafeMutablePointer<Unmanaged<CMSampleBuffer>?> 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31360488/
阅读关于Dispose pattern ,我看到文档反复提到“清理托管和非托管代码”。而在 Dispose 的规范实现中方法,我看到了专门用于清理托管对象与非托管对象的特定流程(取决于 disposi
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
我有一个接收一些参数、分配内存并返回指针的外部方法。 [DllImport("some.dll", CallingConvention = CvInvoke.CvCallingConvention)]
有谁知道如何更改/clr 开关的默认行为以使所有文件在默认情况下不受管理?开关的默认行为是管理所有文件。我知道我可以单独标记每个 .cpp 文件,但是它们有很多... 最佳答案 我最终在项目属性中关闭
F# 支持“非托管”的类型约束。这与“结构”约束之类的值类型约束不同。 MSDN notes非托管约束的行为是: The provided type must be an unmanaged type
我工作的应用程序是一个几乎完全用 Visual C++ 大约在 2003 年编写的 WinForms 应用程序。在我到达现场之前,由于 UI 构建框架而选择了 .NET,但绝大多数代码是在非托管领域开
有时,很难描述一些“我们程序员”可能认为对非程序员和管理类型来说很简单的事情。 所以... 您如何向非程序员描述托管代码(或 Java 字节代码)和非托管/ native 代码之间的区别? 最佳答案
我有一个 fortran dll,我想知道它依赖于 redistribution purpose 的程序集. 我发现的一件事是,dependency walker 没有显示所有的依赖项,即我的程序集依
我观察到带有 unmanaged.dll.manifest 文件标记的 unmanaged.dll 文件。在编辑器中打开此文件时,它似乎是普通的 XML,带有指向某些其他依赖管理的链接?组件。这似乎是
我正在调用一个 DLL,该 DLL 返回一个 void** 结构指针列表,所有类型都相同。 From what I've read ,为了将我的结构从该列表中转换出来,该结构需要被视为非托管。我试图编
我有时在谈论 .NET 时听到/读到它,例如“托管代码”和“非托管代码”,但我不知道它们是什么以及它们有什么区别。根据定义,它们有什么区别?使用其中任何一个的后果是什么?这种区别仅存在于 .NET/W
如何调用以下函数: func AXUIElementCopyAttributeNames(element: AXUIElement!, names: UnsafePointer?>) -> AXErr
我在我的新应用中使用 Swift。在这里,我试图从 AddressBook 访问电子邮件 ID。一切看起来都很好,但最后我变得不受管理了!来自 ABMultiValueCopyValueAtIndex
在分析我的应用程序的内存使用情况时,我遇到过这个图表: 如您所见,在“快照 1”行之前,非托管内存大约占已用内存总量的一半。然后,在“快照 1”和 2 分 55 秒(参见下面的时间线)之后,我强制执行
我想知道 C# 7.3's Unmanaged type constraint提供语言支持以强制类型可 blittable。根据Blittable and Non-Blittable types正确地
我正在使用此处描述的模式来管理处置: http://www.developerzen.com/2006/01/09/finalizableobject-developing-a-base-class-
我们的一个网络应用实例的 CPU 负载很高,我正在尝试调查原因。 AI中记录了一些轮廓痕迹。它们都包含一个很长的“非托管异步”事件。 这个“非托管异步”是什么意思? 最佳答案 .Net 框架发出 ET
我们的一个网络应用实例的 CPU 负载很高,我正在尝试调查原因。 AI中记录了一些轮廓痕迹。它们都包含一个很长的“非托管异步”事件。 这个“非托管异步”是什么意思? 最佳答案 .Net 框架发出 ET
自 Swift 2 起,可以从 Swift 调用采用 C 回调的 C 函数,而无需中间包装器。 许多 C 事件处理 API 都遵循首先创建上下文的模式: struct Context { CF
我想要的是用 swift 将 RSA Sec key 转换为 base64 编码的字符串。所以我初始化了一个变量,如下所示, var publicKeyBits = Unmanaged?() 然后它给
我是一名优秀的程序员,十分优秀!