0

I'm recording audio using an Audio Unit, then writing that data into an NSOutputStream which is part of a bound pair that I'm using to POST that data over HTTP. My problem is the audio unit recording callback and the NSOutputStream hasSpaceAvailable callback are totally independent of one another, so I get buffer underruns very quickly. Is there any way to synchronize those two or map the audio recording callback directly to the NSOutputStream?

Roshan Krishnan
  • 187
  • 1
  • 3
  • 13

1 Answers1

0

According to Apple DTS, you aren't supposed to do any networking or any other synchronization inside the real-time thread Audio Unit callback.

But you don't have to post data directly in your network stream's hasSpaceAvailable callback. You can post data after that callback function has exited, now that you know space is available, when the data becomes available. You can also buffer up a bit of extra audio data in a circular queue or fifo so that that some data is usually available to send to cover network rate variations and latency jitter.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153