Configure AVAudioSession and notification only once when setup.
Change AVAudioSession category to AVAudioSessionCategoryPlayAndRecord.
Register notification AVAudioSessionMediaServicesWereResetNotification.