   fileprivate func removeInput(_ input: CaptureSessionInput) {
     switch input {
     case .video:
-      captureSession.removeInput(videoInput)
+      if let videoInput = videoInput {
+        captureSession.removeInput(videoInput)
+      }
     case .audio:
-      //TODO: Remove audio input.
+      if let audioInput = audioInput {
+        captureSession.removeInput(audioInput)
+      }
       break
     }
   }

    case .video:
      try addVideoInput()
    case .audio:
      //TODO: Add audio input.
      break
    }
  }

  }
  
  /**
   Create `audioInput` and add it to `captureSession`.
   - Throws: `CaptureManagerError.InvalidCaptureInput` if the input cannot be added to `captureSession`.
  */
  fileprivate func addAudioInput() throws {
    let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio)
    audioInput = try AVCaptureDeviceInput(device: audioDevice)
    
    if (!captureSession.canAddInput(audioInput)) {
      throw CaptureManagerError.invalidCaptureInput
    }
    
    captureSession.addInput(audioInput)
  }
  
  /**
   Create `stillImageoutput` and add it to `captureSession`.
   - Throws: `CaptureManagerError.InvalidCaptureOutput` if the output cannot be added to `captureSession`.
   */
