From f914d982af60616ce913e9a7961234b12c4f841c Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Wed, 13 May 2020 15:48:20 -0400 Subject: [PATCH] audio: update audio route only after daemon initialized Change-Id: Ib2e3f54c5a91a473d9b983415584ef2c33f57d60 --- Ring/Ring/AppDelegate.swift | 2 ++ Ring/Ring/Services/AudioService.swift | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Ring/Ring/AppDelegate.swift b/Ring/Ring/AppDelegate.swift index eb95b651e..79bd69153 100644 --- a/Ring/Ring/AppDelegate.swift +++ b/Ring/Ring/AppDelegate.swift @@ -119,6 +119,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // will enumerate and add devices once permission has been granted self.videoService.setupInputs() + self.audioService.connectAudioSignal() + // start monitoring for network changes self.networkService.monitorNetworkType() diff --git a/Ring/Ring/Services/AudioService.swift b/Ring/Ring/Services/AudioService.swift index fe1caf82a..f3c9ce536 100644 --- a/Ring/Ring/Services/AudioService.swift +++ b/Ring/Ring/Services/AudioService.swift @@ -44,16 +44,6 @@ class AudioService { init(withAudioAdapter audioAdapter: AudioAdapter) { self.audioAdapter = audioAdapter - let bluetoothConnected = bluetoothAudioConnected() - let headphonesConnected = headphoneAudioConnected() - isHeadsetConnected.value = bluetoothConnected || headphonesConnected - - // Listen for audio route changes - NotificationCenter.default.addObserver( - self, - selector: #selector(audioRouteChangeListener(_:)), - name: AVAudioSession.routeChangeNotification, - object: nil) } @objc private func audioRouteChangeListener(_ notification: Notification) { @@ -68,6 +58,19 @@ class AudioService { overrideAudioRoute() } + func connectAudioSignal() { + let bluetoothConnected = bluetoothAudioConnected() + let headphonesConnected = headphoneAudioConnected() + isHeadsetConnected.value = bluetoothConnected || headphonesConnected + + // Listen for audio route changes + NotificationCenter.default.addObserver( + self, + selector: #selector(audioRouteChangeListener(_:)), + name: AVAudioSession.routeChangeNotification, + object: nil) + } + func overrideAudioRoute() { let bluetoothConnected = bluetoothAudioConnected() let headphonesConnected = headphoneAudioConnected() -- GitLab