ldenoue/cameraextension

I think this causes high CPU usage

Opened this issue · 4 comments

I've been hammering on my own camera extension for a few months now and the example I was using (which I think was based on your example here) uses DispatchSource.makeTimerSource() to schedule this 3 times every frame instead of calling it continuously.

Your method appeals to me as it feels less hit and miss than polling every few milliseconds and hoping for the best, but it does seem to hike up the CPU usage.

I'm wondering if you've found the same thing and moved on from this way of polling the sample buffer or if there's something I don't know?

Thanks, I really appreciate you putting up this minimal sample - the documentation on this subject is SO thin on the ground! (Will we ever get our promised sample project?? seems unlikely at this point!)

self._streamSink.stream.consumeSampleBuffer(from: client) { sbuf, seq, discontinuity, hasMoreSampleBuffers, err in

This line is probably a better choice to anchor this issue :)

Hi @michaelforrest,
Have you got this high CPU usage issue fixed yet? Would you mind sharing your solution?
Thanks.

I think it's okay as it returns early if there's no buffer. Mine still basically looks like this.

so what's your approach? did you publish it somewhere? Are you polling instead then? I followed a pattern I had found somewhere, but rewrote in Swift, as I can recollect.