开发者

What are the required parameters for CMBufferQueueCreate?

开发者 https://www.devze.com 2023-02-04 14:00 出处:网络
Reading the documentation about iOS SDK CMBufferQueueCreate, it says that getDuration and version are required, all the others callbacks can be NULL.

Reading the documentation about iOS SDK CMBufferQueueCreate, it says that getDuration and version are required, all the others callbacks can be NULL.

But running the following code:

CFAllocatorRef allocator;
CMBufferCallbacks *callbacks;
callbacks = malloc(sizeof(CMBufferCallbacks));
callbacks->version = 0;
callbacks->getDuration = timeC开发者_StackOverflow中文版allback;
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);
}

and queue is:

CMBufferQueueRef* queue;

queue creations fails (queue = 0) and returns a status of:

kCMBufferQueueError_RequiredParameterMissing = -12761,

The callbacks variable is correctly initialized, at least the debugger says so.

Has anybody used the CMBufferQueue?


Presumably there is nothing wrong with the parameters. At least the same as what you wrote is stated in CMBufferQueue.h about the required parameters. But it looks like you are passing a null pointer as the CMBufferQueueRef* parameter. I have updated your sample as follows and it seems to create the message loop 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);

The time callback is still the same.

It does not look like it helps topic starter, but I hope it helps somebody else.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号