title: How do I call CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer?
body: <p>I'm trying to figure out how to call this <code>AVFoundation</code> function in Swift.  I've spent a ton of time fiddling with declarations and syntax, and got this far.  The compiler is mostly happy, but I'm left with one last quandary.</p>
  
  <pre><code>public func captureOutput(
      captureOutput: AVCaptureOutput!,
      didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
      fromConnection connection: AVCaptureConnection!
  ) {
      let samplesInBuffer = CMSampleBufferGetNumSamples(sampleBuffer)
      var audioBufferList: AudioBufferList
  
      var buffer: Unmanaged&lt;CMBlockBuffer&gt;? = nil
  
      CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
          sampleBuffer,
          nil,
          &amp;audioBufferList,
          UInt(sizeof(audioBufferList.dynamicType)),
          nil,
          nil,
          UInt32(kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment),
          &amp;buffer
      )
  
      // do stuff
  }
  </code></pre>
  
  <p>The compiler complains for the 3rd and 4th arguments:</p>
  
  <blockquote>
    <p>Address of variable 'audioBufferList' taken before it is initialized</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Variable 'audioBufferList' used before being initialized</p>
  </blockquote>
  
  <p>So what am I supposed to do here?</p>
  
  <p>I'm working off of <a href="https://stackoverflow.com/a/5031806/2792531">this StackOverflow answer</a> but it's Objective-C.  I'm trying to translate it into Swift, but run into this problem.  </p>
  
  <p>Or is there possibly a better approach?  I need to read the data from the buffer, one sample at a time, so I'm basically trying to get an array of the samples that I can iterate over.</p>