<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMSampleBuffer/withAudioBufferList(blockBufferMemoryAllocator:flags:body:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Media",
      "CoreMedia"
    ],
    "preciseIdentifier" : "s:So17CMSampleBufferRefa9CoreMediaE09withAudioB4List05blockB15MemoryAllocator5flags4bodyxSo011CFAllocatorC0aSg_AbCE5FlagsVx0dG0013UnsafeMutablegbH7PointerV_So07CMBlockbC0atKXEtKlF"
  },
  "title" : "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.

```
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 [CMBlockBuffer](/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

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`](/documentation/CoreMedia/CMSampleBuffer/Flags/audioBufferListAssure16ByteAlignment) flag.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)