     // Restarts the engine after audio output has been changed, like headphones plugged in.
     @objc fileprivate static func restartEngineAfterRouteChange(_ notification: Notification) {
         DispatchQueue.main.async {
-            if shouldBeRunning && !engine.isRunning {
+            if !microphoneLocked && shouldBeRunning && !engine.isRunning {
                 do {
                     try self.engine.start()
                     // Sends notification after restarting the engine, so it is safe to resume

#if !os(tvOS)
import CoreAudioKit
#endif

import Dispatch


            engine.connect(finalMixer.avAudioNode, to: engine.outputNode)
        }
    }
	
	#if os(iOS)
	private static let cx = CTCallCenter()
	private static var microphoneLocked: Bool {
		return cx.currentCalls?.count ?? 0 > 0
	}
	#else
	private static let microphoneLocked = false
	#endif

    // MARK: - Device Management

