---
title: "withAudioBufferList(blockBufferMemoryAllocator:flags:body:)"
framework: coremedia
role: symbol
role_heading: Instance Method
path: "coremedia/cmsamplebuffer/withaudiobufferlist(blockbuffermemoryallocator:flags:body:)"
---

# withAudioBufferList(blockBufferMemoryAllocator:flags:body:)

Calls a closure with an audio buffer list that contains the data from a sample buffer and a block buffer backing the audio buffers.

## Declaration

```swift
func withAudioBufferList<R>(blockBufferMemoryAllocator: CFAllocator? = kCFAllocatorDefault, flags: CMSampleBuffer.Flags = [], body: (UnsafeMutableAudioBufferListPointer, CMBlockBuffer) throws -> R) throws -> R
```

## Parameters

- `blockBufferMemoryAllocator`: An allocator to use for the memory block held by a doc://com.apple.coremedia/documentation/CoreMedia/cmblockbuffer-api.
- `flags`: Optional flags that control the operation.
- `body`: A closure the system calls that contains a pointer to an doc://com.apple.documentation/documentation/CoreAudioTypes/AudioBufferList and the block buffer that backs its audio buffers.

## Discussion

Discussion The system may not copy the data, depending on its contiguity and 16-byte alignment. It guarantees the buffers it places in the AudioBufferList are contiguous. The system returns 16-byte-aligned buffers if you pass the audioBufferListAssure16ByteAlignment flag.

## See Also

### Modifying Sample Buffers

- [dataBuffer](coremedia/cmsamplebuffer/databuffer.md)
- [setDataBuffer(_:)](coremedia/cmsamplebuffer/setdatabuffer(_:).md)
- [imageBuffer](coremedia/cmsamplebuffer/imagebuffer.md)
- [setDataBuffer(fromAudioBufferList:blockBufferMemoryAllocator:flags:)](coremedia/cmsamplebuffer/setdatabuffer(fromaudiobufferlist:blockbuffermemoryallocator:flags:).md)
- [copyPCMData(fromRange:into:)](coremedia/cmsamplebuffer/copypcmdata(fromrange:into:).md)
- [audioStreamPacketDescriptions()](coremedia/cmsamplebuffer/audiostreampacketdescriptions().md)
- [withUnsafeAudioStreamPacketDescriptions(_:)](coremedia/cmsamplebuffer/withunsafeaudiostreampacketdescriptions(_:).md)
- [singleSampleBuffers()](coremedia/cmsamplebuffer/singlesamplebuffers().md)
- [CMSampleBuffer.SingleSampleBuffers](coremedia/cmsamplebuffer/singlesamplebuffers.md)
