How to mute input audio during capture session

I'm following the documentation here to capture video and audio.
https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/avcam_building_a_camera_app

I want to mute the input audio during parts of the capture session.

I can create an audio connection like this and mute the audio using the "enabled" property.

Code Block
AVCaptureConnection *audioConnection = [movieFileOutput connectionWithMediaType:AVMediaTypeAudio];
audioConnection.enabled = NO;


However, when I try to set this property later to "YES" the capture session stops recording with this error.

Code Block
Movie file finishing error: Error Domain=AVFoundationErrorDomain Code=-11818 "Recording Stopped"


How do I mute and unmute input audio during a capture session?