 	//
 	// Audio Output
 	//
-	
+
 	static private var speakerEnabled: Bool = false
-	
+
 	init() {
-        let shouldManualInit = Bundle.main.object(forInfoDictionaryKey: "ManualInitAudioDevice") as? String
-    
-        if(shouldManualInit == "FALSE") {
-            PluginRTCAudioController.initAudioDevices()
-        }
-		
+		let shouldManualInit = Bundle.main.object(forInfoDictionaryKey: "ManualInitAudioDevice") as? String
+
+		if(shouldManualInit == "FALSE") {
+			PluginRTCAudioController.initAudioDevices()
+		}
+
 		NotificationCenter.default.addObserver(
 			self,
 			selector: #selector(self.audioRouteChangeListener(_:)),
 			name: AVAudioSession.routeChangeNotification,
 			object: nil)
 	}
-	
+
 	@objc dynamic fileprivate func audioRouteChangeListener(_ notification:Notification) {
 		let audioRouteChangeReason = notification.userInfo![AVAudioSessionRouteChangeReasonKey] as! UInt
-		
+
 		switch audioRouteChangeReason {
 		case AVAudioSession.RouteChangeReason.newDeviceAvailable.rawValue:
 			NSLog("PluginRTCAudioController#audioRouteChangeListener() | headphone plugged in")

			(value:AVAudioSessionPortDescription) -> Bool in
			return value.uid == inputDeviceUID
		})[0]
		
		PluginRTCAudioController.audioInputSelected = audioInput
	}
	
	// Setter function inserted by set specific audio device
	static func restoreInputOutputAudioDevice() -> Void {
		let audioSession: AVAudioSession = AVAudioSession.sharedInstance()
		
		do {
			try audioSession.setPreferredInput(PluginRTCAudioController.audioInputSelected)
		} catch {
			NSLog("PluginRTCAudioController:restoreInputOutputAudioDevice: Error setting audioSession preferred input.")
		}
		
		PluginRTCAudioController.setOutputSpeakerIfNeed(enabled: speakerEnabled);
	}
	
	static func setOutputSpeakerIfNeed(enabled: Bool) {
		
		speakerEnabled = enabled
		
		let audioSession: AVAudioSession = AVAudioSession.sharedInstance()
		let currentRoute = audioSession.currentRoute
		
		if currentRoute.outputs.count != 0 {
			for description in currentRoute.outputs {
				if (

					NSLog("PluginRTCAudioController#setOutputSpeakerIfNeed() | external audio output plugged in -> do nothing")
				} else {
					NSLog("PluginRTCAudioController#setOutputSpeakerIfNeed() | external audio pulled out")

					if (speakerEnabled) {
						do {
							try audioSession.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
