1

What is the most efficient way to convert audio CMSampleBuffer buffers to MTLBuffer buffers? I would also like to efficiently as possible convert MTLBuffer buffers back to CMSampleBuffer buffers.

Do I need to first convert audio CMSampleBuffer to NSData, then use makeBuffer(bytesNoCopy pointer: UnsafeMutableRawPointer, length: Int, ...)? Or is there a more direct approach?

Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
  • Are you operating on audio or video sample buffers? Either way, you shouldn't need to go through `NSData`; you can ask a sample buffer for its corresponding block buffer or image buffer, from which you can get a raw pointer to the data. You'll probably want to take a copy in each direction if you're going to be processing with Metal; otherwise you'll be holding onto resources that might be in a tightly-constrained pool (e.g. a `CVPixelBufferPool`) for longer than they should strictly be kept alive. – warrenm May 17 '17 at 17:52
  • Thanks to your amazing help I already have pixel buffers working. Now I am trying to add some audio processing. Thanks for the advice. – Jeshua Lacock May 17 '17 at 22:04

0 Answers0