@@ -57,15 +57,15 @@ class Application {
5757 }
5858
5959 self . settings = Settings ( )
60-
60+
6161 Networking . startMonitor ( )
6262
6363 checkDriver {
6464 Sources . getInputPermission {
6565 AudioDevice . register = true
6666 audioPipelineIsRunningListener = audioPipelineIsRunning. once {
6767 self . setupUI {
68- if ( User . isFirstLaunch || Constants . DEBUG ) {
68+ if ( User . isFirstLaunch) {
6969 UI . show ( )
7070 } else {
7171 UI . close ( )
@@ -81,7 +81,6 @@ class Application {
8181 // Create a Sentry client and start crash handler
8282 SentrySDK . start { options in
8383 options. dsn = Constants . SENTRY_ENDPOINT
84- options. sampleRate = 0.1
8584
8685 // Only send crash reports if user gave consent
8786 options. beforeSend = { event in
@@ -303,18 +302,6 @@ class Application {
303302 output = Output ( device: selectedDevice!)
304303 outputCreated. emit ( )
305304
306- selectedDeviceIsAliveListener = AudioDeviceEvents . on (
307- . isAliveChanged,
308- onDevice: selectedDevice!,
309- retain: false
310- ) {
311- // If device that we are sending audio to goes offline we need to stop and switch to a different device
312- if ( selectedDevice!. isAlive ( ) == false ) {
313- Console . log ( " Current device dies so switching to built it " )
314- selectOutput ( device: AudioDevice . builtInOutputDevice) // TODO: Replace with a known device from stack
315- }
316- }
317-
318305 selectedDeviceSampleRateChangedListener = AudioDeviceEvents . on (
319306 . nominalSampleRateChanged,
320307 onDevice: selectedDevice!,
@@ -448,6 +435,20 @@ class Application {
448435 stopRemoveEngines ( )
449436 Storage . synchronize ( )
450437 }
438+
439+ static func handleSleep ( ) {
440+ stopSave ( )
441+ }
442+
443+ static func handleWakeUp ( ) {
444+ Utilities . delay ( 1000 ) {
445+ if ( AudioDevice . allOutputDevices ( ) . contains ( where: { $0. id == selectedDevice? . id } ) ) {
446+ startPassthrough ( )
447+ } else {
448+ restart ( )
449+ }
450+ }
451+ }
451452
452453 static func quit ( ) {
453454 stopSave ( )
@@ -514,7 +515,7 @@ class Application {
514515 }
515516
516517 static private let dispatchActionQueue = DispatchQueue ( label: " dispatchActionQueue " , qos: . userInitiated)
517- // Custom dispatch function. Need to execute all dispatches on the main thread
518+ // Custom dispatch function. Need to execute some dispatches on the main thread
518519 static func dispatchAction( _ action: Action , onMainThread: Bool = true ) {
519520 if ( onMainThread) {
520521 DispatchQueue . main. async {
0 commit comments