Instance Method


Sets the delegate that will accept captured buffers and the dispatch queue on which the delegate will be called.


func setSampleBufferDelegate(_ sampleBufferDelegate: AVCaptureAudioDataOutputSampleBufferDelegate?, queue sampleBufferCallbackQueue: DispatchQueue?)



An object conforming to the AVCaptureAudioDataOutputSampleBufferDelegate protocol that will receive sample buffers after they are captured.


You must pass a serial dispatch to guarantee that audio samples will be delivered in order.

The value may not be NULL, except when setting the sampleBufferDelegate to nil.


When a new audio sample buffer is captured it is vended to the sample buffer delegate using the captureOutput(_:didOutput:from:) delegate method. All delegate methods are called on the specified dispatch queue.

If the queue is blocked when new samples are captured, those samples will be automatically dropped when they become sufficiently late. This allows you to process existing samples on the same queue without having to manage the potential memory usage increases that would otherwise occur when that processing is unable to keep up with the rate of incoming samples.

If you need to minimize the chances of samples being dropped, you should specify a queue on which a sufficiently small amount of processing is being done outside of receiving sample buffers. When migrating extra processing to another queue, you are responsible for ensuring that memory usage does not grow without bound from samples that have not been processed.

Special Considerations

This method uses dispatch_retain and dispatch_release to manage the queue.

See Also

Receiving Captured Audio Data

var sampleBufferCallbackQueue: DispatchQueue?

The queue on which delegate callbacks are invoked

protocol AVCaptureAudioDataOutputSampleBufferDelegate

Methods for receiving audio sample data from an audio capture.