1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-22 13:07:26 +03:00

update 0.3.0

This commit is contained in:
nodeful 2020-06-21 19:30:52 +01:00
parent 33554360c3
commit 36c0180cb4
16 changed files with 173 additions and 38 deletions

Binary file not shown.

View File

@ -18,6 +18,7 @@ import SwiftyJSON
import ServiceManagement
import ReSwift
import Sparkle
import AudioKit
enum VolumeChangeDirection: String {
case UP = "UP"
@ -71,6 +72,14 @@ class Application {
static public func start () {
// AudioKit Engine fucks with Driver installation, eqMac doesn't use it's engine anyway
try? AudioKit.stop()
try? AudioKit.shutdown()
AKSettings.audioInputEnabled = false
AKSettings.enableRouteChangeHandling = false
AKSettings.notificationsEnabled = false
AudioKit.engine.stop()
setupSettings()
if (!Constants.DEBUG) {
@ -117,7 +126,7 @@ class Application {
) { install in
if install {
Driver.install(started: {
UI.showLoadingWindow("Installing eqMac audio driver")
UI.showLoadingWindow("Installing eqMac audio driver\nIf this process takes too long, please restart your Mac")
}) { success in
if (success) {
UI.hideLoadingWindow()
@ -131,16 +140,16 @@ class Application {
quit()
}
}
} else if (Driver.isOutdated) {
} else if (Driver.isOutdated && Driver.skipCurrentVersion) {
Alert.confirm(
title: "Audio Driver Update",
message: "There is an optional Audio Driver update that should improve user experience. \nIn order to update eqMac will ask for your System Password. \nPlease close any apps playing audio (Spotify, YouTube etc.) otherwise installation might fail.",
okText: "Update Driver",
cancelText: "Skip update"
cancelText: "Skip Driver update"
) { update in
if update {
Driver.install(started: {
UI.showLoadingWindow("Updating eqMac audio driver")
UI.showLoadingWindow("Updating eqMac audio driver\nIf this process takes too long, please restart your Mac")
}) { success in
if (success) {
UI.hideLoadingWindow()
@ -150,6 +159,7 @@ class Application {
}
}
} else {
Driver.skipCurrentVersion = true
completion()
}
}
@ -161,7 +171,7 @@ class Application {
private static func driverFailedToInstallPrompt () {
UI.hideLoadingWindow()
Alert.confirm(
title: "Driver failed to install", message: "Unfortunately the audio driver has failed to install. You can restart eqMac and try again or quit.", okText: "Try again", cancelText: "Quit") { restart in
title: "Driver failed to install", message: "Unfortunately the audio driver has failed to install. You can restart eqMac and try again or quit. Alternatively, please try to restart your Mac and running eqMac again.", okText: "Try again", cancelText: "Quit") { restart in
if restart {
return self.restart()
} else {
@ -258,7 +268,7 @@ class Application {
try! AudioDeviceEvents.recreateEventEmitters([.isAliveChanged, .volumeChanged, .nominalSampleRateChanged])
self.setupDriverDeviceEvents()
Utilities.delay(500) {
createAudioPipeline()
createAudioPipeline()
}
}
}
@ -288,12 +298,12 @@ class Application {
return
}
let gain = Double(Driver.device!.virtualMasterVolume(direction: .playback)!)
Console.log(gain)
if (gain <= 1 && gain != Application.store.state.effects.volume.gain) {
Application.dispatchAction(VolumeAction.setGain(gain, false))
}
}
AudioDeviceEvents.on(.muteChanged, onDevice: Driver.device!) {
if (ignoreNextDriverMuteEvent) {
ignoreNextDriverMuteEvent = false
@ -513,29 +523,30 @@ class Application {
updater.checkForUpdates(nil)
}
static func reinstallDriver (_ completion: @escaping () -> Void) {
static func reinstallDriver (_ completion: @escaping (Bool) -> Void) {
Alert.confirm(
title: "Audio Driver Reinstall",
message: "\nIn order to reinstall the driver eqMac we will ask for your System Password. \nPlease close any apps playing audio (Spotify, YouTube etc.) otherwise installation might fail.",
message: "\nIn order to reinstall the driver eqMac we will ask for your System Password. \nPlease close any apps playing audio (Spotify, YouTube etc.) otherwise installation might fail. eqMac will restart after this.",
cancelText: "Cancel"
) { reinstall in
if reinstall {
Driver.install(started: {
UI.showLoadingWindow("Installing eqMac audio driver")
self.stopListeners()
self.stopEngines()
self.switchBackToLastKnownDevice()
UI.close()
Utilities.delay(100) { UI.showLoadingWindow("Reinstalling eqMac driver\nIf this process takes too long, please restart your Mac") }
}) { success in
if (success) {
UI.hideLoadingWindow()
setupAudio()
completion()
completion(true)
Application.restart()
} else {
driverFailedToInstallPrompt()
}
}
} else {
completion()
completion(false)
}
}
@ -546,8 +557,8 @@ class Application {
self.stopListeners()
self.stopEngines()
self.switchBackToLastKnownDevice()
UI.hide()
Utilities.delay(100) { UI.showLoadingWindow("Uninstalling eqMac") }
UI.close()
Utilities.delay(100) { UI.showLoadingWindow("Uninstalling eqMac\nIf this process takes too long, please restart your Mac") }
}) { success in
completion(success)
if (success) {

View File

@ -23,7 +23,8 @@ class ApplicationDataBus: DataBus {
return [
"name": host.localizedName as AnyObject,
"model": Sysctl.model as String,
"version": Bundle.main.infoDictionary?["CFBundleVersion"] as Any
"version": Bundle.main.infoDictionary?["CFBundleVersion"] as Any,
"driverVersion": Driver.lastInstalledVersion
]
}
@ -59,6 +60,17 @@ class ApplicationDataBus: DataBus {
return nil
}
self.on(.GET, "/driver/reinstall/available") { _, res in
return "Yes"
}
self.on(.GET, "/driver/reinstall") { _, res in
Application.reinstallDriver { success in
res.send([ "reinstalled": success ])
}
return nil
}
self.on(.GET, "/update") { _, _ in
Application.checkForUpdates()
return "Checking for updates."

View File

@ -36,10 +36,10 @@ enum AudioDeviceEventType {
class AudioDeviceEvents: EventSubscriber {
static var events = AudioDeviceEvents()
static var listeners: [EmitterKit.EventListener<AudioDevice>] = [] as! [EmitterKit.EventListener<AudioDevice>]
var hashValue: Int = 1
static var listeners: [EmitterKit.EventListener<AudioDevice>] = [] as! [EmitterKit.EventListener<AudioDevice>]
var subscribed = false
// Per Device
let isJackConnectedChangedEvent = EmitterKit.Event<AudioDevice>()
let isRunningSomewhereChangedEvent = EmitterKit.Event<AudioDevice>()
@ -63,17 +63,34 @@ class AudioDeviceEvents: EventSubscriber {
let inputChangedEvent = EmitterKit.Event<AudioDevice>()
let systemDeviceChangedEvent = EmitterKit.Event<AudioDevice>()
init () {
NotificationCenter.defaultCenter.subscribe(
self,
eventType: AudioHardwareEvent.self,
dispatchQueue: DispatchQueue.main
)
NotificationCenter.defaultCenter.subscribe(
self,
eventType: AudioDeviceEvent.self,
dispatchQueue: DispatchQueue.main
)
func subscribe () {
if !subscribed {
NotificationCenter.defaultCenter.subscribe(
self,
eventType: AudioHardwareEvent.self,
dispatchQueue: DispatchQueue.main
)
NotificationCenter.defaultCenter.subscribe(
self,
eventType: AudioDeviceEvent.self,
dispatchQueue: DispatchQueue.main
)
subscribed = true
}
}
func unsubscribe () {
NotificationCenter.defaultCenter.unsubscribe(self, eventType: AudioHardwareEvent.self)
NotificationCenter.defaultCenter.unsubscribe(self, eventType: AudioDeviceEvent.self)
subscribed = false
}
static func subscribe () {
events.subscribe()
}
static func unsubscribe () {
events.unsubscribe()
}
internal func eventReceiver(_ event: AMCoreAudio.Event) {
@ -102,6 +119,7 @@ class AudioDeviceEvents: EventSubscriber {
}
static func recreateEventEmitters(_ eventsToRecreate: [AudioDeviceEventType]) throws {
subscribe()
for event in eventsToRecreate {
switch event {
case .isAliveChanged:
@ -184,6 +202,7 @@ class AudioDeviceEvents: EventSubscriber {
@discardableResult
static func on (_ event: AudioDeviceEventType, retain: Bool = true, _ handler: @escaping (AudioDevice) -> Void) -> EmitterKit.EventListener<AudioDevice> {
events.subscribe()
let emitter = getEventEmitterFromEventType(event)
let listener: EmitterKit.EventListener<AudioDevice> = emitter.on(handler)
if (retain) {
@ -199,6 +218,7 @@ class AudioDeviceEvents: EventSubscriber {
@discardableResult
static func once (_ event: AudioDeviceEventType, _ handler: @escaping (AudioDevice) -> Void) -> EmitterKit.EventListener<AudioDevice> {
events.subscribe()
let emitter = getEventEmitterFromEventType(event)
let listener: EmitterKit.EventListener<AudioDevice> = emitter.once(handler: handler)
return listener
@ -223,12 +243,14 @@ class AudioDeviceEvents: EventSubscriber {
}
static func start () {
subscribe()
for listener in listeners {
listener.isListening = true
}
}
static func stop () {
unsubscribe()
for listener in listeners {
listener.isListening = false
}

View File

@ -64,6 +64,24 @@ class Driver {
return info["CFBundleVersion"] as! String
}
static var lastSkippedDriverVersion: String? {
get {
return Storage[.lastSkippedDriverVersion]
}
set {
Storage[.lastSkippedDriverVersion] = newValue
}
}
static var skipCurrentVersion: Bool {
get {
return lastSkippedDriverVersion == bundledVersion
}
set {
lastSkippedDriverVersion = newValue ? bundledVersion : nil
}
}
static var isOutdated: Bool {
get {
return bundledVersion != lastInstalledVersion

View File

@ -27,6 +27,7 @@ extension DefaultsKeys {
// Effects - Equalizer - Advanced
static let advancedEqualizerPresets = DefaultsKey<[AdvancedEqualizerPreset]?>("advancedEqualizerPresets")
static let lastInstalledDriverVersion = DefaultsKey<String?>("lastInstalledDriverVersion")
static let lastSkippedDriverVersion = DefaultsKey<String?>("lastSkippedDriverVersion")
}
let Storage = Defaults

View File

@ -219,6 +219,10 @@ class UI: StoreSubscriber {
load()
}
static func reload () {
viewController.webView.reload()
}
func setupBridge () {
bridge = Bridge(webView: UI.viewController.webView)
}
@ -251,7 +255,7 @@ class UI: StoreSubscriber {
}
private func load () {
Networking.isReachable(UI.domain) { reachable in
remoteIsReachable() { reachable in
if reachable {
Console.log("Loading Remote UI")
UI.viewController.load(Constants.UI_ENDPOINT_URL)
@ -263,7 +267,33 @@ class UI: StoreSubscriber {
UI.viewController.load(url)
}
}
}
private func remoteIsReachable (_ completion: @escaping (Bool) -> Void) {
var returned = false
AF.request(Constants.UI_ENDPOINT_URL)
.responseData { response in
switch response.result {
case .success:
if !returned {
returned = true
completion(true)
}
case .failure:
Console.log("Failed to load \(Constants.UI_ENDPOINT_URL)", response)
if !returned {
returned = true
completion(false)
}
}
}
Utilities.delay(1000) {
if (!returned) {
returned = true
completion(false)
}
}
}
private func cacheRemote () {

View File

@ -12,8 +12,8 @@ import Cocoa
class Window: NSWindow, NSWindowDelegate {
override init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool) {
super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag)
self.isOneShot = false
self.titleVisibility = .hidden
self.titlebarAppearsTransparent = true
self.isMovableByWindowBackground = true

View File

@ -32,6 +32,8 @@
<false/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSExceptionDomains</key>
<dict/>
</dict>

View File

@ -1038,7 +1038,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.2.3;
CURRENT_PROJECT_VERSION = 0.3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = JZA6C97KJA;
ENABLE_HARDENED_RUNTIME = YES;
@ -1074,7 +1074,7 @@
"$(PROJECT_DIR)/Source/Vendor",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = v0.2.3;
MARKETING_VERSION = v0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.bitgapp.eqmac;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1098,7 +1098,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.2.3;
CURRENT_PROJECT_VERSION = 0.3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = JZA6C97KJA;
ENABLE_HARDENED_RUNTIME = YES;
@ -1134,7 +1134,7 @@
"$(PROJECT_DIR)/Source/Vendor",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = v0.2.3;
MARKETING_VERSION = v0.3;
PRODUCT_BUNDLE_IDENTIFIER = com.bitgapp.eqmac;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -72,6 +72,7 @@ void EQM_Clients::RemoveClient(const UInt32 inClientID)
{
mEQMAppClientID = -1;
}
}
#pragma mark IO Status

View File

@ -1,6 +1,6 @@
{
"name": "eqmac",
"version": "1.1.0",
"version": "1.2.0",
"scripts": {
"start": "ng serve",
"build": "rm -rf dist/ && ng build --prod && cd dist/ && zip -r -D ui.zip * -x '*.DS_Store' && cp ui.zip ../../native/app/Embedded",

View File

@ -2,4 +2,5 @@
<div fxLayout="row" fxLayoutAlign="space-around center">
<eqm-label style="margin-top: 10px;">UI Version: {{uiVersion}}</eqm-label>
<eqm-label *ngIf="info" style="margin-top: 10px;">App Version: {{info.version}}</eqm-label>
<eqm-label style="margin-top: 10px;">Driver Version: {{info.driverVersion || '1.0.0'}}</eqm-label>
</div>

View File

@ -65,6 +65,14 @@ export class SettingsComponent implements OnInit {
label: 'Check for Updates',
action: this.update.bind(this)
}
reinstallDriverOption: ButtonOption = {
key: 'reinstall-driver',
type: 'button',
label: 'Reinstall Driver',
action: this.reinstallDriver.bind(this)
}
settings: Options = [
[
this.updateOption
@ -86,12 +94,24 @@ export class SettingsComponent implements OnInit {
public app: ApplicationService,
public dialog: MatDialog,
private ui: UIService
) {}
) {
this.getDriverReinstallAvailable()
}
ngOnInit () {
this.sync()
}
async getDriverReinstallAvailable () {
if (await this.app.getDriverReinstallAvailable()) {
this.settings[3].unshift(this.reinstallDriverOption)
}
}
async reinstallDriver () {
this.app.reinstallDriver()
}
async sync () {
await Promise.all([
this.syncSettings()

View File

@ -5,6 +5,7 @@ export interface MacInfo {
name: string
model: string
version: string
driverVersion?: string
}
@Injectable({
providedIn: 'root'
@ -33,4 +34,20 @@ export class ApplicationService extends DataService {
update () {
return this.request({ method: 'GET', endpoint: '/update' })
}
async getDriverReinstallAvailable () {
return new Promise(async (resolve) => {
setTimeout(() => resolve(false), 1000)
try {
await this.request({ method: 'GET', endpoint: '/driver/reinstall/available' })
resolve(true)
} catch (err) {
resolve(false)
}
})
}
reinstallDriver () {
return this.request({ method: 'GET', endpoint: '/driver/reinstall' })
}
}