CMBufferQueueCreate
的 Reading the documentation,它表示需要getDuration
和版本,其他所有回调都可以为NULL。
但运行以下代码:
CFAllocatorRef allocator;
CMBufferCallbacks *callbacks;
callbacks = malloc(sizeof(CMBufferCallbacks));
callbacks->version = 0;
callbacks->getDuration = timeCallback;
callbacks->refcon = NULL;
callbacks->getDecodeTimeStamp = NULL;
callbacks->getPresentationTimeStamp = NULL;
callbacks->isDataReady = NULL;
callbacks->compare = NULL;
callbacks->dataBecameReadyNotification = NULL;
CMItemCount capacity = 4;
OSStatus s = CMBufferQueueCreate(allocator, capacity, callbacks, queue);
NSLog(@"QUEUE: %x", queue);
NSLog(@"STATUS: %i", s);
with timeCallback:
CMTime timeCallback(CMBufferRef buf, void *refcon){
return CMTimeMake(1, 1);
}
和队列是:
CMBufferQueueRef* queue;
队列创建失败(queue = 0)并返回状态:
kCMBufferQueueError_RequiredParameterMissing = -12761,
callbacks
变量已正确初始化,至少调试器是这样说的。
是否有人使用CMBufferQueue
?
答案 0 :(得分:1)
据推测,参数没有任何问题。至少与你所写的相同,在CMBufferQueue.h中说明了所需的参数。但看起来你传递一个空指针作为CMBufferQueueRef *参数。我已按如下方式更新了您的示例,它似乎创建了消息循环OK。
CMBufferQueueRef queue;
CFAllocatorRef allocator = kCFAllocatorDefault;
CMBufferCallbacks *callbacks;
callbacks = malloc(sizeof(CMBufferCallbacks));
callbacks->version = 0;
callbacks->getDuration = timeCallback;
callbacks->refcon = NULL;
callbacks->getDecodeTimeStamp = NULL;
callbacks->getPresentationTimeStamp = NULL;
callbacks->isDataReady = NULL;
callbacks->compare = NULL;
callbacks->dataBecameReadyNotification = NULL;
CMItemCount capacity = 4;
OSStatus s = CMBufferQueueCreate(allocator, capacity, callbacks, &queue);
NSLog(@"QUEUE: %x", queue);
NSLog(@"STATUS: %i", s);
时间回调仍然相同。
它看起来不像主题启动器,但我希望它能帮助其他人。