How does toggling AVAudioSession active state affect the AVAudioPlayerNode

Every time the AVAudioSession category is re-activated ( after being inactivated) and the audioengine is restarted (calling stop() and play()), the output from audioplayer node seems to ignore the audio session category, until explicitly connecting the audio player node again using

audioEngine.connect(playerNode, 
                    to: audioEngine.outputNode, 
                    format: audioFile.processingFormat)

The documentation regarding this behavior is not clear and would like to clarify the following.

  • Should audioEngine.connect be called everytime the AVAudioSession is activated?
  • Should audioEngine.connect be called after the audio player engine is stopped (audioEngine.stop())?