Contents

CMAudioSampleBufferCreateWithPacketDescriptions(allocator:dataBuffer:dataReady:makeDataReadyCallback:refcon:formatDescription:sampleCount:presentationTimeStamp:packetDescriptions:sampleBufferOut:)

Creates a sample buffer with packet descriptions and a callback to make the data ready for use.

Declaration

func CMAudioSampleBufferCreateWithPacketDescriptions(allocator: CFAllocator?, dataBuffer: CMBlockBuffer?, dataReady: Bool, makeDataReadyCallback: CMSampleBufferMakeDataReadyCallback?, refcon makeDataReadyRefcon: UnsafeMutableRawPointer?, formatDescription: CMFormatDescription, sampleCount numSamples: CMItemCount, presentationTimeStamp: CMTime, packetDescriptions: UnsafePointer<AudioStreamPacketDescription>?, sampleBufferOut: UnsafeMutablePointer<CMSampleBuffer?>) -> OSStatus

Parameters

  • allocator:

    The allocator to use for allocating the CMSampleBuffer object. Pass kCFAllocatorDefault to use the default allocator.

  • dataBuffer:

    CMBlockBuffer for the media data. This can be NULL, a CMBlockBuffer with no backing memory, a CMBlockBuffer with backing memory but no data yet, or a CMBlockBuffer that already contains the media data. If CMBlockBuffer contains the media data, dataReady should be true.

  • dataReady:

    Indicates whether or not the BlockBuffer already contains the media data.

  • makeDataReadyCallback:

    Callback that CMSampleBufferMakeDataReady should call to make the data ready. Can be NULL.

  • makeDataReadyRefcon:

    The reference constant, Cmsamplebuffermakedataready(_:), that this function should pass to the callback.

  • formatDescription:

    A description of the media data’s format. Can’t be NULL.

  • numSamples:

    Number of samples in the CMSampleBuffer. Must not be 0.

  • presentationTimeStamp:

    Timestamp of the first sample in the buffer. Must be a numeric CMTime.

  • packetDescriptions:

    Array of packetDescriptions, one for each of numSamples. May be NULL if the samples are known to have a constant number of frames per packet and a constant size.

  • sampleBufferOut:

    On output, points to the newly created CMSampleBuffer.

Return Value

A result code. See Sample Buffer Error Codes.

Discussion

Provides an optimization over CMSampleBufferCreate() when the caller already has packetDescriptions for the audio data. This routine uses the packetDescriptions to create the sizing and timing arrays required to make the sample buffer if necessary.

Topics

Callbacks

See Also

Creating Sample Buffers