0

I'm reading from a AudioUnit using a AudioUnitRender() call in a loop on a dedicated thread.

Most of the time it returns CannotDoInCurrentContext, but it also randomly works (every 10 calls or so) giving me audio data.

My Audio Units are arranged as follows mic -> VoiceProcessingIO -> FormatConverter

My render call is to the FormatConverter

I also have playback with: FormatConverter -> VoiceProcessingIO -> Speaker This uses the same VoiceProcessingIO but a different formatter.

I've tried putting a sleep in after the error but this doesn't make it work any more often in relation to the failures. It makes it work less often in real time but at the same ratio in relation to the failures.

I cant use render callbacks for this because they never fire on the formatter, it seems that it uses a pull model and nothing does the pulling if I don't.

Some reading seems to indicate that this error means that it couldn't get a lock required to do the render. But I can't see anyway to wait for the lock to be free.

trampster
  • 8,598
  • 4
  • 37
  • 52

1 Answers1

0

AudioUnitRender is only designed to run in the audio context, which only happens for an app during Audio Unit callbacks. You can try putting the render call in your output callback.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153