title: How do I avoid the following error: AVAudioEngineGraph required condition is false: NULL != tap
body: <p>I've searched this error and I haven't found anyone with the same error. I'm pretty sure I know what this error means, but I don't know how to avoid it. </p>
  
  <p>Basically what's happening is I have a phone call over MultipeerConnectivity. I'm using an AVAudioEngine to record audio and play audio from the peer. </p>
  
  <p>I've noticed that there was a pretty big delay between the time that the user was talking and the time it would take for the other device to play that audio, but I fixed the issue by removing the tap and reinstalling it. This completely removes any delay. However, sometimes it throws an error. </p>
  
  <p>I also allow the user to mute their mic, and when they click mute, the tap is removed. Once they click unmute, the tap is reinstalled. Again sometimes this also throws the same error: </p>
  
  <p>AVAudioEngineGraph.mm:2707: InputAvailable: required condition is false: NULL != tap</p>
  
  <p>This error seems to be completely random though. Sometimes it happens, other times it doesn't. I haven't been able to consistently reproduce the error. </p>
  
  <hr>
  
  <p>My guess is that this is because it's trying to install a tap where a tap already exists, but I don't know how to avoid it. I guess I could just increment the bus that the tap is being installed on, but this doesn't seem like the best option. </p>
  
  <p>I also looked to see if there was a property on AVAudioInputNode that would tell me if there was already a tap installed on a particular bus, but I didn't seem to find any. </p>
  
  <p>Does anyone have any experience with this issue?</p>