0

One of the recent sample codes from Apple uses same serial queue for receiving samples from AVCaptureVideoDataOutput and AVCaptureAudioDataOutput delegate. I need to know if this is acceptable practice from performance standpoint. Should one have different or single queue for both the sample buffer delegates? Particularly in the setting of multiple camera inputs/outputs, this becomes significant.

 private let dataOutputQueue = DispatchQueue(label: "data output queue")
 ...
 ...
 videoDataOutput.setSampleBufferDelegate(self, queue: dataOutputQueue)
 audioDataOutput.setSampleBufferDelegate(self, queue: dataOutputQueue)
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

1 Answers1

0

I guess when it comes to performance:

  1. It always depends on your situation. Perhaps for Apple's sample it was okay but maybe in your situation it really needs more.
  2. It's something you can try out for yourself. Try to get as many inputs as possible on the slowest device and see if the performance is still good enough.

There's a similar question where the performance wasn't good because of serial queues and the answer was to use concurrent queues, see here: Performance issues when using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

But once again, I suggest you try it out and see what works for you :)

Update

Here's a link that perfectly explains the differences and how to work with serial & concurrent queues: https://www.avanderlee.com/swift/concurrent-serial-dispatchqueue/

Bob de Graaf
  • 2,630
  • 1
  • 25
  • 43
  • I saw that question, but the weird thing about that answer is to use concurrent queue. AVCaptureVideoDataOutput documentation (https://developer.apple.com/documentation/avfoundation/avcapturevideodataoutput/1389008-setsamplebufferdelegate) specifies use of only serial queues however. – Deepak Sharma Nov 25 '19 at 16:34
  • Well what they say is this: "You must use a serial dispatch queue, to guarantee that video frames will be delivered in order." Which they say mainly because of the last part of the sentence -> to make sure the frames are in the right order. But you were talking about multiple camera inputs. If you simply use serial queues for each camera input, it will still be alright. Also, I just updated my answer with a link for concurrent queues. – Bob de Graaf Nov 26 '19 at 08:39