---
title: "AudioQueueEnqueueBuffer(_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audioqueueenqueuebuffer(_:_:_:_:)"
---

# AudioQueueEnqueueBuffer(_:_:_:_:)

Adds a buffer to the buffer queue of a recording or playback audio queue.

## Declaration

```swift
func AudioQueueEnqueueBuffer(_ inAQ: AudioQueueRef, _ inBuffer: AudioQueueBufferRef, _ inNumPacketDescs: UInt32, _ inPacketDescs: UnsafePointer<AudioStreamPacketDescription>?) -> OSStatus
```

## Parameters

- `inAQ`: The audio queue that owns the audio queue buffer.
- `inBuffer`: The audio queue buffer to add to the buffer queue.
- `inNumPacketDescs`: The number of packets of audio data in the inBuffer parameter. Use a value of 0 for any of the following situations: When playing a constant bit rate (CBR) format. When the audio queue is a recording (input) audio queue. When the buffer you are reenqueuing was allocated with the doc://com.apple.audiotoolbox/documentation/AudioToolbox/AudioQueueAllocateBufferWithPacketDescriptions(_:_:_:_:) function. In this case, your callback should describe the buffer’s packets in the buffer’s mPacketDescriptions and mPacketDescriptionCount fields.
- `inPacketDescs`: An array of packet descriptions. Use a value of NULL for any of the following situations: When playing a constant bit rate (CBR) format. When the audio queue is an input (recording) audio queue. When the buffer you are reenqueuing was allocated with the doc://com.apple.audiotoolbox/documentation/AudioToolbox/AudioQueueAllocateBufferWithPacketDescriptions(_:_:_:_:) function. In this case, your callback should describe the buffer’s packets in the buffer’s mPacketDescriptions and mPacketDescriptionCount fields.

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion Audio queue callbacks use this function to reenqueue buffers—placing them “last in line” in a buffer queue. A playback (or output) callback reenqueues a buffer after the buffer is filled with fresh audio data (typically from a file). A recording (or input) callback reenqueues a buffer after the buffer’s contents were written (typically to a file).

## See Also

### Handling Audio Queue Buffers

- [AudioQueueAllocateBuffer(_:_:_:)](audiotoolbox/audioqueueallocatebuffer(_:_:_:).md)
- [AudioQueueAllocateBufferWithPacketDescriptions(_:_:_:_:)](audiotoolbox/audioqueueallocatebufferwithpacketdescriptions(_:_:_:_:).md)
- [AudioQueueFreeBuffer(_:_:)](audiotoolbox/audioqueuefreebuffer(_:_:).md)
- [AudioQueueEnqueueBufferWithParameters(_:_:_:_:_:_:_:_:_:_:)](audiotoolbox/audioqueueenqueuebufferwithparameters(_:_:_:_:_:_:_:_:_:_:).md)
