in BasicBroadcast/ViewControllers/LiveBroadcastViewController.swift [234:247]
func setMicrophone(_ device: IVSDeviceDescriptor) {
guard let broadcastSession = self.broadcastSession else { return }
// either attach or exchange based on current state.
if attachedMicrophone == nil {
broadcastSession.attach(device, toSlotWithName: nil) { newDevice, _ in
self.attachedMicrophone = newDevice
}
} else if let currentMic = self.attachedMicrophone, currentMic.descriptor().urn != device.urn {
broadcastSession.exchangeOldDevice(currentMic, withNewDevice: device) { newDevice, _ in
self.attachedMicrophone = newDevice
}
}
}