Reusing AudioUnit Graphics on iOS

I use two AUGraphs in my iOS application, one for recording audio and one for playing audio. I use only one at a time. This works great if I create AUGraph instances every time I start using them.

I am trying to reuse these AUGraphs instead of creating and initializing a new instance each time every time I switch between recording and playback.

I am having problems with this because when I perform the following steps, I get an error message the next time I try to get microphone data from the I / O unit:

  • schedule recording
  • initialize recording schedule
  • start recording schedule
  • stop recording schedule
  • schedule playback
  • initialize the playback schedule
  • start of playback schedule
  • stop playback schedule
  • start recording schedule

And then the call that causes the error, return code -50 (this statement works fine when you recreate the AUGraph every time):

OSStatus status = AudioUnitRender( remoteIoUnit, ioActionFlags, inTimeStamp, CB_remoteIoUnitInputElement, inNumberFrames, ioData ); 

Is reuse of AUGraphs even possible, and if so, how?

+4
source share
1 answer

You can reuse the AU chart exactly as described in the question.

The problem, why this did not work for me, is that I had an error causing interference / overwriting between my two AUGraph instances. I found these errors only by accident. Since I fixed them, AUGraphs works as intended.

If the two AUGraph instances are completely separate, you can use and reuse as many AUGraph instances as you want. I have not tested whether they can be used at the same time.

+2
source

Source: https://habr.com/ru/post/1490774/


All Articles