CMBlockBufferCreateWithMemoryBlock(allocator:memoryBlock:blockLength:blockAllocator:customBlockSource:offsetToData:dataLength:flags:blockBufferOut:)
Creates a block buffer that’s backed by a memory block.
Declaration
func CMBlockBufferCreateWithMemoryBlock(allocator structureAllocator: CFAllocator?, memoryBlock: UnsafeMutableRawPointer?, blockLength: Int, blockAllocator: CFAllocator?, customBlockSource: UnsafePointer<CMBlockBufferCustomBlockSource>?, offsetToData: Int, dataLength: Int, flags: CMBlockBufferFlags, blockBufferOut: UnsafeMutablePointer<CMBlockBuffer?>) -> OSStatusParameters
- structureAllocator:
Allocator to use for allocating the
CMBlockBufferobject. PassNULLto use the default allocator. - memoryBlock:
Block of memory to hold buffered data. If
NULL, a memory block will be allocated when needed (via a call toCMBlockBufferAssureBlockMemoryusing the providedblockAllocatororcustomBlockSource. If non-NULL, the block will be used and will be deallocated when the newCMBlockBufferis finalized (i.e. released for the last time). - blockLength:
Overall length of the memory block in bytes. Must not be zero. This is the size of the supplied memory block or the size to allocate if
memoryBlockisNULL. - blockAllocator:
Allocator to be used for allocating the
memoryBlock, ifmemoryBlockisNULL. IfmemoryBlockis non-NULL, this allocator will be used to deallocate it if provided. PassingNULLwill cause the default allocator (as set at the time of the call) to be used. PasskCFAllocatorNullif no deallocation is desired. - customBlockSource:
If non-
NULL, it will be used for the allocation and freeing of the memory block (theblockAllocatorparameter is ignored). If provided, and thememoryBlockparameter isNULL, itsAllocateBlock()routine must be non-NULL. Allocate will be called once, if successful, when thememoryBlockis allocated.FreeBlock()will be called once when theCMBlockBufferis disposed. - offsetToData:
Offset within the
memoryBlockat which theCMBlockBuffershould refer to data. - dataLength:
Number of relevant data bytes, starting at
offsetToData, within the memory block. - flags:
Feature and control flags.
- blockBufferOut:
Receives newly-created
CMBlockBufferobject with a retain count of 1. Must not beNULL.
Return Value
Returns kCMBlockBufferNoErr if successful.
Discussion
Creates a new CMBlockBuffer backed by a memory block. The memory block may be statically allocated, dynamically allocated using the given allocator (or customBlockSource) or not yet allocated. The returned CMBlockBuffer may be further expanded using CMBlockBufferAppendMemoryBlock and/or CMBlockBufferAppendBufferReference.
See Also
Creating a Block Buffer
CMBlockBufferCreateEmpty(allocator:capacity:flags:blockBufferOut:)CMBlockBufferCreateWithBufferReference(allocator:referenceBuffer:offsetToData:dataLength:flags:blockBufferOut:)CMBlockBufferCreateContiguous(allocator:sourceBuffer:blockAllocator:customBlockSource:offsetToData:dataLength:flags:blockBufferOut:)CMBlockBufferFlagsBlock Buffer FlagsCMBlockBufferCustomBlockSourceCustom Block Source Version