---
title: "withUnsafeAudioBufferList(_:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avreadonlyaudiopcmbuffer/withunsafeaudiobufferlist(_:)"
---

# withUnsafeAudioBufferList(_:)

Provides scoped read-only access to the audio buffer list.

## Declaration

```swift
func withUnsafeAudioBufferList<R>(_ body: (UnsafePointer<AudioBufferList>) throws -> R) rethrows -> R
```

## Parameters

- `body`: A closure that receives a pointer to the audio buffer list.

## Return Value

Return Value The value returned by the closure.

## Discussion

Discussion warning: Although the AudioBufferList pointer is const, each AudioBuffer within the list exposes mData as UnsafeMutableRawPointer. You must not modify the buffer data through these pointers. Doing so results in undefined behavior and violates the read-only contract of this type.

## See Also

### Accessing channel data

- [channelData(_:)](avfaudio/avreadonlyaudiopcmbuffer/channeldata(_:).md)
- [AVReadOnlyAudioPCMBuffer.ChannelData](avfaudio/avreadonlyaudiopcmbuffer/channeldata.md)
