Skip to content

Commit

Permalink
fixed crash related to volume compensation when quitting and ui tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeful committed Nov 14, 2021
1 parent c81d927 commit 729a03d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion native/app/Source/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
}

func applicationWillTerminate(_ aNotification: Notification) {
Application.quit()
Application.handleTermination()
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
Expand Down
15 changes: 11 additions & 4 deletions native/app/Source/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,13 @@ class Application {

if (globalGain < 0) {
if (device.canSetVirtualMasterVolume(direction: .playback)) {
var decibels = device.virtualMasterVolumeInDecibels(direction: .playback)!
var decibels =
device.volumeInDecibels(channel: 0, direction: .playback)
?? device.volumeInDecibels(channel: 1, direction: .playback)
?? 0.5
decibels = decibels + Float(globalGain)
device.setVirtualMasterVolume(device.decibelsToScalar(volume: decibels, channel: 1, direction: .playback)!, direction: .playback)
let newVolume = device.decibelsToScalar(volume: decibels, channel: 0, direction: .playback) ?? device.decibelsToScalar(volume: decibels, channel: 1, direction: .playback) ?? 0.1
device.setVirtualMasterVolume(newVolume, direction: .playback)
} else if (device.canSetVolume(channel: 1, direction: .playback)) {
var decibels = device.volumeInDecibels(channel: 1, direction: .playback)!
decibels = decibels + Float(globalGain)
Expand Down Expand Up @@ -576,13 +580,16 @@ class Application {
}
}

static func quit (_ completion: (() -> Void)? = nil) {
static func quit () {
NSApp.terminate(nil)
}

static func handleTermination (_ completion: (() -> Void)? = nil) {
stopSave {
Driver.hidden = true
if completion != nil {
completion!()
}
NSApp.terminate(nil)
}
}

Expand Down
4 changes: 1 addition & 3 deletions native/app/Source/ApplicationDataBus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ApplicationDataBus: DataBus {
super.init(route: route, bridge: bridge)

self.on(.GET, "/quit") { _, res in
Application.quit {
res.send(JSON("Application Quit"))
}
Application.quit()
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class AppComponent implements OnInit, AfterContentInit {

const cdkOverlays = document.getElementsByClassName('cdk-overlay-pane')
for (let i = 0; i < cdkOverlays.length; i++) {
cdkOverlays[i].setAttribute('style', `transform: scale(${this.ui.scale.toFixed(2)}); max-width: ${Math.round(90 / this.ui.scale)}vw`)
cdkOverlays[i].setAttribute('style', `transform: scale(${this.ui.scale.toFixed(2)}); width: ${Math.round(90 / this.ui.scale)}vw`)
}
return style
}
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ import { UIService } from './services/ui.service'
useValue: {
...new MatDialogConfig(),
hasBackdrop: true,
maxWidth: 10,
width: '10px'
disableClose: false
} as MatDialogConfig
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,7 @@ export class EqualizersComponent implements OnInit, OnDestroy {
if (!this.app.enabled || !this.enabled) {
return this.clicked()
}
const width = '90vw'
this.settingsDialog = this.dialog.open(OptionsDialogComponent, {
hasBackdrop: true,
disableClose: false,
width: width,
maxWidth: width,
panelClass: 'options-dialog-container',
data: {
options: this.activeEqualizer.settings,
title: `${this.type} Equalizer Settings`
Expand Down

0 comments on commit 729a03d

Please sign in to comment.