---
title: "CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(_:bufferListSizeNeededOut:bufferListOut:bufferListSize:blockBufferAllocator:blockBufferMemoryAllocator:flags:blockBufferOut:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmsamplebuffergetaudiobufferlistwithretainedblockbuffer(_:bufferlistsizeneededout:bufferlistout:bufferlistsize:blockbufferallocator:blockbuffermemoryallocator:flags:blockbufferout:)"
---

# CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(_:bufferListSizeNeededOut:bufferListOut:bufferListSize:blockBufferAllocator:blockBufferMemoryAllocator:flags:blockBufferOut:)

Returns an audio buffer list that contains the media data.

## Declaration

```swift
func CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(_ sbuf: CMSampleBuffer, bufferListSizeNeededOut: UnsafeMutablePointer<Int>?, bufferListOut: UnsafeMutablePointer<AudioBufferList>?, bufferListSize: Int, blockBufferAllocator blockBufferStructureAllocator: CFAllocator?, blockBufferMemoryAllocator blockBufferBlockAllocator: CFAllocator?, flags: UInt32, blockBufferOut: UnsafeMutablePointer<CMBlockBuffer?>?) -> OSStatus
```

## Parameters

- `sbuf`: CMSampleBuffer being accessed.
- `bufferListSizeNeededOut`: Receives the size of the AudioBufferList required to accommodate the data. May be NULL.
- `bufferListOut`: Allocated by the caller, sized as specified by bufferListSizeNeededOut. It’s filled in with pointers into the retained blockBufferOut. May be NULL.
- `bufferListSize`: Size of the bufferListOut allocated by the client. If bufferListOut isn’t NULL and bufferListSize is insufficient, kFigSampleBufferError_ArrayTooSmall is returned.
- `blockBufferStructureAllocator`: Allocator to use when creating the CMBlockBuffer structure.
- `blockBufferBlockAllocator`: Allocator to use for memory block held by the CMBlockBuffer.
- `flags`: Flags controlling operation.
- `blockBufferOut`: The retained CMBlockBuffer.

## Return Value

Return Value A result code. See Sample Buffer Error Codes.

## Discussion

Discussion Creates an AudioBufferList containing the data from the CMSampleBuffer, and a CMBlockBuffer which references (and manages the lifetime of) the data in that AudioBufferList. The data may or may not be copied, depending on the contiguity and 16-byte alignment of the sample buffer’s data. The buffers placed in the AudioBufferList are guaranteed to be contiguous. The buffers in the AudioBufferList will be 16-byte-aligned if kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment is passed in.

## See Also

### Modifying Sample Buffers

- [CMSampleBufferGetDataBuffer(_:)](coremedia/cmsamplebuffergetdatabuffer(_:).md)
- [CMSampleBufferSetDataBuffer(_:newValue:)](coremedia/cmsamplebuffersetdatabuffer(_:newvalue:).md)
- [CMSampleBufferGetImageBuffer(_:)](coremedia/cmsamplebuffergetimagebuffer(_:).md)
- [CMSampleBufferSetDataBufferFromAudioBufferList(_:blockBufferAllocator:blockBufferMemoryAllocator:flags:bufferList:)](coremedia/cmsamplebuffersetdatabufferfromaudiobufferlist(_:blockbufferallocator:blockbuffermemoryallocator:flags:bufferlist:).md)
- [CMSampleBufferCopyPCMDataIntoAudioBufferList(_:at:frameCount:into:)](coremedia/cmsamplebuffercopypcmdataintoaudiobufferlist(_:at:framecount:into:).md)
- [CMSampleBufferGetAudioStreamPacketDescriptions(_:allocatedSize:packetDescriptionsOut:packetDescriptionsSizeNeededOut:)](coremedia/cmsamplebuffergetaudiostreampacketdescriptions(_:allocatedsize:packetdescriptionsout:packetdescriptionssizeneededout:).md)
- [CMSampleBufferGetAudioStreamPacketDescriptionsPtr(_:packetDescriptionsPointerOut:sizeOut:)](coremedia/cmsamplebuffergetaudiostreampacketdescriptionsptr(_:packetdescriptionspointerout:sizeout:).md)
