Say we have an AVCaptureAudioDataOutput
object that has been set up with an AVCaptureSession
to get data samples from the device's microphone.
captureOutput(_:didOutput:from:)
in AVCaptureAudioDataOutputSampleBufferDelegate
always gets called with 2048 bytes of samples. Is it possible to set a preferred sample buffer size?
A basic example:
let output = AVCaptureAudioDataOutput()
output.setSampleBufferDelegate(delegate, queue)
// Add output to AVCaptureSession and start the capture session once everything is set up
...
// In the delegate
public func captureOutput(_ output: AVCaptureOutput,
didOutput sampleBuffer: CMSampleBuffer,
from connection: AVCaptureConnection) {
// sampleBuffer is 2048 bytes, but I want less
let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer)
print(CMBlockBufferGetDataLength(blockBuffer!)) // 2048
...
}