Function

AudioQueueEnqueueBuffer

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

Declaration

OSStatus AudioQueueEnqueueBuffer(AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, UInt32 inNumPacketDescs, const AudioStreamPacketDescription *inPacketDescs);

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 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 AudioQueueAllocateBufferWithPacketDescriptions function. In this case, your callback should describe the buffer’s packets in the buffer’s mPacketDescriptions and mPacketDescriptionCount fields.

Return Value

A result code. See Result Codes.

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

Asks an audio queue object to allocate an audio queue buffer.

AudioQueueAllocateBufferWithPacketDescriptions

Asks an audio queue object to allocate an audio queue buffer with space for packet descriptions.

AudioQueueFreeBuffer

Asks an audio queue to dispose of an audio queue buffer.

AudioQueueEnqueueBufferWithParameters

Adds a buffer to the buffer queue of a playback audio queue object, specifying start time and other settings.