iOS Developer Library

Developer

AVFoundation Framework Reference AVCaptureAudioDataOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVCaptureAudioDataOutput

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.0 and later.

AVCaptureAudioDataOutput is a concrete sub-class of AVCaptureOutput that you use, via its delegate, to process audio sample buffers from the audio being captured.

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

    Declaration

    Swift

    func setSampleBufferDelegate(_ sampleBufferDelegate: AVCaptureAudioDataOutputSampleBufferDelegate!, queue sampleBufferCallbackQueue: dispatch_queue_t!)

    Objective-C

    - (void)setSampleBufferDelegate:(id<AVCaptureAudioDataOutputSampleBufferDelegate>)sampleBufferDelegate queue:(dispatch_queue_t)sampleBufferCallbackQueue

    Parameters

    sampleBufferDelegate

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

    sampleBufferCallbackQueue

    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.

    Discussion

    When a new audio sample buffer is captured it is vended to the sample buffer delegate using the captureOutput:didOutputSampleBuffer:fromConnection: 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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The capture object’s delegate. (read-only)

    Declaration

    Swift

    var sampleBufferDelegate: AVCaptureAudioDataOutputSampleBufferDelegate! { get }

    Objective-C

    @property(nonatomic, readonly) id< AVCaptureAudioDataOutputSampleBufferDelegate > sampleBufferDelegate

    Discussion

    You use the delegate to manage incoming data.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • The queue on which delegate callbacks are invoked (read-only)

    Declaration

    Swift

    var sampleBufferCallbackQueue: dispatch_queue_t! { get }

    Objective-C

    @property(nonatomic, readonly) dispatch_queue_t sampleBufferCallbackQueue

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.