How to avoid the following error: AVAudioEngineGraph condition is false: NULL! = Tap

I have searched for this error and I haven't found anyone with the same error. I'm sure I know what this error means, but I don't know how to avoid it.

Basically what happens is I have a phone call through MultipeerConnectivity. I am using AVAudioEngine for audio recording and audio playback from peer side.

I noticed that there was a very large delay between the time the user spoke and the time it would take for another device to play this sound, but I fixed the problem by removing the tap and reinstalling it. This completely eliminates any delay. However, this sometimes causes an error.

I also allow the user to mute the microphone and when they click the Mute button the tap is removed. As soon as they press the unmute button, the tap is reset. Again, sometimes this also throws the same error:

AVAudioEngineGraph.mm:2707: InputAvailable: Required condition is false: NULL! = Tap

This error seems completely random. Sometimes it happens, sometimes it doesn't. I have not been able to consistently reproduce the error.


I guess this is because it is trying to install a faucet where the faucet already exists, but I don't know how to avoid it. I could probably just increase the tire the tap is pushing on, but that doesn't seem like the best option.

I also looked to see if there is a property on AVAudioInputNode that will tell me if a tap has already been set on a particular bus, but I can't seem to find it.

Does anyone have any experience with this problem?

+3


source to share


1 answer


If you find a better solution please let me know what it is. This is not a 100% complete solution, but it was the best I could find with the little help I got from this problem.

I have found several workarounds, however, there will probably still be a better solution. This doesn't completely fix the problem, I've seen the problem once or twice since I made the change, but it definitely lowers the chances of it.

Basically what I did when I removed the faucet be sure to wait for it to finish before allowing the faucet to be installed. In my case, I had a mute button and was not forcing the user to touch the button faster than the tap could be removed. So once the button is touched, I don't allow any clicks until the faucet is removed and then reactivate the button.



Second, I'm not sure if this does anything at all, but before setting tap on inputNode I always call inputNode.reset () and then inputNode.removeTap (onBus: 0) and then set tap.

inputNode.reset()
inputNode.removeTap(onBus: 0)
inputNode.installTap(onBus: 0, bufferSize: 4096, format: localInputFormat) {
    ...
}

      

+1


source







All Articles