mirror of
https://github.com/bitgapp/eqMac.git
synced 2024-11-22 13:07:26 +03:00
improvements to sleep handling
This commit is contained in:
parent
a6a1344bba
commit
b1f9f702c9
@ -30,14 +30,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
|
||||
Application.start()
|
||||
}
|
||||
|
||||
Networking.checkConnected { connected in
|
||||
if (connected) {
|
||||
self.updater.checkForUpdatesInBackground()
|
||||
} else {
|
||||
if (Application.store.state.settings.doAutoCheckUpdates) {
|
||||
Networking.checkConnected { connected in
|
||||
if (connected) {
|
||||
self.updater.checkForUpdatesInBackground()
|
||||
} else {
|
||||
self.updateProcessed.emit()
|
||||
}
|
||||
}
|
||||
|
||||
Utilities.delay(2000) {
|
||||
self.updateProcessed.emit()
|
||||
}
|
||||
}
|
||||
Utilities.delay(2000) {
|
||||
} else {
|
||||
self.updateProcessed.emit()
|
||||
}
|
||||
|
||||
@ -106,11 +111,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
|
||||
}
|
||||
|
||||
@objc func willSleep(event: NSNotification) {
|
||||
Application.stopSave()
|
||||
Application.handleSleep()
|
||||
}
|
||||
|
||||
@objc func didWakeUp(event: NSNotification) {
|
||||
Application.restart()
|
||||
Application.handleWakeUp()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class Application {
|
||||
AudioDevice.register = true
|
||||
audioPipelineIsRunningListener = audioPipelineIsRunning.once {
|
||||
self.setupUI {
|
||||
if (User.isFirstLaunch || Constants.DEBUG) {
|
||||
if (User.isFirstLaunch) {
|
||||
UI.show()
|
||||
} else {
|
||||
UI.close()
|
||||
@ -81,7 +81,6 @@ class Application {
|
||||
// Create a Sentry client and start crash handler
|
||||
SentrySDK.start { options in
|
||||
options.dsn = Constants.SENTRY_ENDPOINT
|
||||
options.sampleRate = 0.1
|
||||
|
||||
// Only send crash reports if user gave consent
|
||||
options.beforeSend = { event in
|
||||
@ -303,18 +302,6 @@ class Application {
|
||||
output = Output(device: selectedDevice!)
|
||||
outputCreated.emit()
|
||||
|
||||
selectedDeviceIsAliveListener = AudioDeviceEvents.on(
|
||||
.isAliveChanged,
|
||||
onDevice: selectedDevice!,
|
||||
retain: false
|
||||
) {
|
||||
// If device that we are sending audio to goes offline we need to stop and switch to a different device
|
||||
if (selectedDevice!.isAlive() == false) {
|
||||
Console.log("Current device dies so switching to built it")
|
||||
selectOutput(device: AudioDevice.builtInOutputDevice) // TODO: Replace with a known device from stack
|
||||
}
|
||||
}
|
||||
|
||||
selectedDeviceSampleRateChangedListener = AudioDeviceEvents.on(
|
||||
.nominalSampleRateChanged,
|
||||
onDevice: selectedDevice!,
|
||||
@ -449,6 +436,20 @@ class Application {
|
||||
Storage.synchronize()
|
||||
}
|
||||
|
||||
static func handleSleep () {
|
||||
stopSave()
|
||||
}
|
||||
|
||||
static func handleWakeUp () {
|
||||
Utilities.delay(1000) {
|
||||
if (AudioDevice.allOutputDevices().contains(where: { $0.id == selectedDevice?.id })) {
|
||||
startPassthrough()
|
||||
} else {
|
||||
restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func quit () {
|
||||
stopSave()
|
||||
Driver.hidden = true
|
||||
@ -514,7 +515,7 @@ class Application {
|
||||
}
|
||||
|
||||
static private let dispatchActionQueue = DispatchQueue(label: "dispatchActionQueue", qos: .userInitiated)
|
||||
// Custom dispatch function. Need to execute all dispatches on the main thread
|
||||
// Custom dispatch function. Need to execute some dispatches on the main thread
|
||||
static func dispatchAction(_ action: Action, onMainThread: Bool = true) {
|
||||
if (onMainThread) {
|
||||
DispatchQueue.main.async {
|
||||
|
@ -28,6 +28,7 @@ class Outputs {
|
||||
|
||||
static func shouldAutoSelect (_ device: AudioDevice) -> Bool {
|
||||
let types: [TransportType] = [.bluetooth, .bluetoothLE, .builtIn]
|
||||
Console.log(device.nominalSampleRate(), device.sourceName, device.actualSampleRate(), device.isOutputOnlyDevice())
|
||||
return isDeviceAllowed(device) && types.contains(device.transportType!)
|
||||
}
|
||||
|
||||
|
@ -267,14 +267,16 @@ class UI: StoreSubscriber {
|
||||
}
|
||||
|
||||
func newState(state: UIState) {
|
||||
if (state.height != UI.height) {
|
||||
UI.height = state.height
|
||||
}
|
||||
if (state.width != UI.width) {
|
||||
UI.width = state.width
|
||||
}
|
||||
if (state.mode != UI.mode) {
|
||||
UI.mode = state.mode
|
||||
DispatchQueue.main.async {
|
||||
if (state.height != UI.height) {
|
||||
UI.height = state.height
|
||||
}
|
||||
if (state.width != UI.width) {
|
||||
UI.width = state.width
|
||||
}
|
||||
if (state.mode != UI.mode) {
|
||||
UI.mode = state.mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,11 @@ class UIDataBus: DataBus {
|
||||
return "Hidden"
|
||||
}
|
||||
|
||||
self.on(.GET, "/height") { _, _ in
|
||||
return [ "height": self.state.height ]
|
||||
self.on(.GET, "/height") { _, res in
|
||||
DispatchQueue.main.async {
|
||||
res.send([ "height": self.state.height ])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
self.on(.POST, "/height") { data, _ in
|
||||
@ -44,8 +47,11 @@ class UIDataBus: DataBus {
|
||||
return "UI Height has been set"
|
||||
}
|
||||
|
||||
self.on(.GET, "/width") { data, _ in
|
||||
return [ "width": self.state.width ]
|
||||
self.on(.GET, "/width") { _, res in
|
||||
DispatchQueue.main.async {
|
||||
res.send([ "width": self.state.width ])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
self.on(.POST, "/width") { data, _ in
|
||||
@ -86,8 +92,11 @@ class UIDataBus: DataBus {
|
||||
throw "Please provide a valid 'uiMode' parameter."
|
||||
}
|
||||
|
||||
self.on(.GET, "/shown") { data, _ in
|
||||
return JSON([ "isShown": UI.isShown ])
|
||||
self.on(.GET, "/shown") { data, res in
|
||||
DispatchQueue.main.async {
|
||||
res.send([ "isShown": UI.isShown ])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
self.on(.POST, "/loaded") { _, _ in
|
||||
|
@ -32,6 +32,7 @@ export class OutputsComponent implements OnInit {
|
||||
case 'builtIn': return output.name === 'Headphones' ? 'headphones' : 'speaker'
|
||||
case 'displayPort': return 'displayport'
|
||||
case 'fireWire': return 'firewire'
|
||||
case 'virtual': return 'cog'
|
||||
default: return output.transportType
|
||||
}
|
||||
})()
|
||||
|
@ -13,7 +13,8 @@ export type DeviceTransportType =
|
||||
'pci' |
|
||||
'thunderbolt' |
|
||||
'usb' |
|
||||
'aggregate'
|
||||
'aggregate' |
|
||||
'virtual'
|
||||
|
||||
export interface Output {
|
||||
id: number
|
||||
|
@ -121,7 +121,14 @@ and make it a more stable product.
|
||||
otaUpdatesOption: CheckboxOption = {
|
||||
type: 'checkbox',
|
||||
value: false,
|
||||
label: 'OTA User Interface Updates',
|
||||
label: 'OTA Updates',
|
||||
tooltip: `
|
||||
Because eqMac's User Interface is built with Web Technologies
|
||||
the developer can periodically push Over the Air (OTA) updates,
|
||||
make minor bug fixes and UI improvements,
|
||||
all without needing the user to do a full app update.
|
||||
`,
|
||||
tooltipAsComponent: true,
|
||||
toggled: doOTAUpdates => {
|
||||
this.settingsService.setDoOTAUpdates({
|
||||
doOTAUpdates
|
||||
|
Loading…
Reference in New Issue
Block a user