Question

I use two AUGraphs in my iOS app, one for recording audio and one for playing audio. I use only one at a time. This works fine as long as I recreate the AUGraph instances from scratch everytime I start to use them.

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

I'm having problems to do this, because when doing the following steps, I get an error the next time I try to fetch microphone data from the I/O unit:

  • compose recording graph
  • initialize recording graph
  • start recording graph
  • stop recording graph
  • compose playback graph
  • initialize playback graph
  • start playback graph
  • stop playback graph
  • start recording graph

And then the call which causes the error, a return code of -50 (this statement works fine when recreating the AUGraph every time):

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

Is reusing AUGraphs generally possible, and if so, how?

Était-ce utile?

La solution

It is possible to reuse an AU Graph exactly in the same way as described in the question.

The problem why it did not work for me was that I had a bug which caused interferences/overwritings between my two AUGraph instances. I found these bugs only by chance. Since I fixed them, the AUGraphs work as intended.

When keeping the two AUGraph instances completely separate, you can use and reuse as many AUGraph instances as you like. I did not test if they can be used simultaneously.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top