CMBlockBufferAppendMemoryBlock(_:memoryBlock:length:blockAllocator:customBlockSource:offsetToData:dataLength:flags:)
Adds a memory block to an existing block buffer.
Declaration
func CMBlockBufferAppendMemoryBlock(_ theBuffer: CMBlockBuffer, memoryBlock: UnsafeMutableRawPointer?, length blockLength: Int, blockAllocator: CFAllocator?, customBlockSource: UnsafePointer<CMBlockBufferCustomBlockSource>?, offsetToData: Int, dataLength: Int, flags: CMBlockBufferFlags) -> OSStatusParameters
- theBuffer:
The existing
CMBlockBufferto which the newmemoryBlockwill be added. Must not beNULL - memoryBlock:
Block of memory to hold buffered data. If
NULL, a memory block will be allocated when needed (via a call toCMBlockBufferAssureBlockMemory) using the providedblockAllocatororcustomBlockSource. If non-NULL, the block will be used and will be deallocated when theCMBlockBufferis 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
memoryBlockor the size to allocate ifmemoryBlockisNULL. - 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 (the
blockAllocatorparameter 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:
The reference maintained by the existing
CMBlockBufferwill begin after this offset within thememoryBlock. - dataLength:
Number of relevant data bytes, starting at
offsetToData, within the memory block. - flags:
Feature and control flags
Return Value
Returns kCMBlockBufferNoErr if successful.
Discussion
Adds a memoryBlock to an existing CMBlockBuffer. The memory block may be statically allocated, dynamically allocated using the given allocator or not yet allocated. The CMBlockBuffer's total data length will be increased by the specified dataLength. If the kCMBlockBufferAssureMemoryNowFlag is set in the flags parameter, the memory block is allocated immediately using the blockAllocator or customBlockSource. Note that append operations are not thread safe, so care must be taken when appending to block buffers that are used by multiple threads.
See Also
Modifying a Block Buffer
CMBlockBufferAppendBufferReference(_:targetBBuf:offsetToData:dataLength:flags:)CMBlockBufferAssureBlockMemory(_:)CMBlockBufferAccessDataBytes(_:atOffset:length:temporaryBlock:returnedPointerOut:)CMBlockBufferCopyDataBytes(_:atOffset:dataLength:destination:)CMBlockBufferReplaceDataBytes(with:blockBuffer:offsetIntoDestination:dataLength:)CMBlockBufferFillDataBytes(with:blockBuffer:offsetIntoDestination:dataLength:)