1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-22 22:32:17 +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 ServiceManagement
import ReSwift import ReSwift
import Sparkle import Sparkle
import AudioKit
enum VolumeChangeDirection: String { enum VolumeChangeDirection: String {
case UP = "UP" case UP = "UP"
@ -71,6 +72,14 @@ class Application {
static public func start () { 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() setupSettings()
if (!Constants.DEBUG) { if (!Constants.DEBUG) {
@ -117,7 +126,7 @@ class Application {
) { install in ) { install in
if install { if install {
Driver.install(started: { 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 }) { success in
if (success) { if (success) {
UI.hideLoadingWindow() UI.hideLoadingWindow()
@ -131,16 +140,16 @@ class Application {
quit() quit()
} }
} }
} else if (Driver.isOutdated) { } else if (Driver.isOutdated && Driver.skipCurrentVersion) {
Alert.confirm( Alert.confirm(
title: "Audio Driver Update", 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.", 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", okText: "Update Driver",
cancelText: "Skip update" cancelText: "Skip Driver update"
) { update in ) { update in
if update { if update {
Driver.install(started: { 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 }) { success in
if (success) { if (success) {
UI.hideLoadingWindow() UI.hideLoadingWindow()
@ -150,6 +159,7 @@ class Application {
} }
} }
} else { } else {
Driver.skipCurrentVersion = true
completion() completion()
} }
} }
@ -161,7 +171,7 @@ class Application {
private static func driverFailedToInstallPrompt () { private static func driverFailedToInstallPrompt () {
UI.hideLoadingWindow() UI.hideLoadingWindow()
Alert.confirm( 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 { if restart {
return self.restart() return self.restart()
} else { } else {
@ -258,7 +268,7 @@ class Application {
try! AudioDeviceEvents.recreateEventEmitters([.isAliveChanged, .volumeChanged, .nominalSampleRateChanged]) try! AudioDeviceEvents.recreateEventEmitters([.isAliveChanged, .volumeChanged, .nominalSampleRateChanged])
self.setupDriverDeviceEvents() self.setupDriverDeviceEvents()
Utilities.delay(500) { Utilities.delay(500) {
createAudioPipeline() createAudioPipeline()
} }
} }
} }
@ -288,12 +298,12 @@ class Application {
return return
} }
let gain = Double(Driver.device!.virtualMasterVolume(direction: .playback)!) let gain = Double(Driver.device!.virtualMasterVolume(direction: .playback)!)
Console.log(gain)
if (gain <= 1 && gain != Application.store.state.effects.volume.gain) { if (gain <= 1 && gain != Application.store.state.effects.volume.gain) {
Application.dispatchAction(VolumeAction.setGain(gain, false)) Application.dispatchAction(VolumeAction.setGain(gain, false))
} }
} }
AudioDeviceEvents.on(.muteChanged, onDevice: Driver.device!) { AudioDeviceEvents.on(.muteChanged, onDevice: Driver.device!) {
if (ignoreNextDriverMuteEvent) { if (ignoreNextDriverMuteEvent) {
ignoreNextDriverMuteEvent = false ignoreNextDriverMuteEvent = false
@ -513,29 +523,30 @@ class Application {
updater.checkForUpdates(nil) updater.checkForUpdates(nil)
} }
static func reinstallDriver (_ completion: @escaping () -> Void) { static func reinstallDriver (_ completion: @escaping (Bool) -> Void) {
Alert.confirm( Alert.confirm(
title: "Audio Driver Reinstall", 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" cancelText: "Cancel"
) { reinstall in ) { reinstall in
if reinstall { if reinstall {
Driver.install(started: { Driver.install(started: {
UI.showLoadingWindow("Installing eqMac audio driver")
self.stopListeners() self.stopListeners()
self.stopEngines() self.stopEngines()
self.switchBackToLastKnownDevice() self.switchBackToLastKnownDevice()
UI.close()
Utilities.delay(100) { UI.showLoadingWindow("Reinstalling eqMac driver\nIf this process takes too long, please restart your Mac") }
}) { success in }) { success in
if (success) { if (success) {
UI.hideLoadingWindow() UI.hideLoadingWindow()
setupAudio() completion(true)
completion() Application.restart()
} else { } else {
driverFailedToInstallPrompt() driverFailedToInstallPrompt()
} }
} }
} else { } else {
completion() completion(false)
} }
} }
@ -546,8 +557,8 @@ class Application {
self.stopListeners() self.stopListeners()
self.stopEngines() self.stopEngines()
self.switchBackToLastKnownDevice() self.switchBackToLastKnownDevice()
UI.hide() UI.close()
Utilities.delay(100) { UI.showLoadingWindow("Uninstalling eqMac") } Utilities.delay(100) { UI.showLoadingWindow("Uninstalling eqMac\nIf this process takes too long, please restart your Mac") }
}) { success in }) { success in
completion(success) completion(success)
if (success) { if (success) {

View File

@ -23,7 +23,8 @@ class ApplicationDataBus: DataBus {
return [ return [
"name": host.localizedName as AnyObject, "name": host.localizedName as AnyObject,
"model": Sysctl.model as String, "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 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 self.on(.GET, "/update") { _, _ in
Application.checkForUpdates() Application.checkForUpdates()
return "Checking for updates." return "Checking for updates."

View File

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

View File

@ -64,6 +64,24 @@ class Driver {
return info["CFBundleVersion"] as! String 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 { static var isOutdated: Bool {
get { get {
return bundledVersion != lastInstalledVersion return bundledVersion != lastInstalledVersion

View File

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

View File

@ -219,6 +219,10 @@ class UI: StoreSubscriber {
load() load()
} }
static func reload () {
viewController.webView.reload()
}
func setupBridge () { func setupBridge () {
bridge = Bridge(webView: UI.viewController.webView) bridge = Bridge(webView: UI.viewController.webView)
} }
@ -251,7 +255,7 @@ class UI: StoreSubscriber {
} }
private func load () { private func load () {
Networking.isReachable(UI.domain) { reachable in remoteIsReachable() { reachable in
if reachable { if reachable {
Console.log("Loading Remote UI") Console.log("Loading Remote UI")
UI.viewController.load(Constants.UI_ENDPOINT_URL) UI.viewController.load(Constants.UI_ENDPOINT_URL)
@ -263,7 +267,33 @@ class UI: StoreSubscriber {
UI.viewController.load(url) 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 () { private func cacheRemote () {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "eqmac", "name": "eqmac",
"version": "1.1.0", "version": "1.2.0",
"scripts": { "scripts": {
"start": "ng serve", "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", "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"> <div fxLayout="row" fxLayoutAlign="space-around center">
<eqm-label style="margin-top: 10px;">UI Version: {{uiVersion}}</eqm-label> <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 *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> </div>

View File

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

View File

@ -5,6 +5,7 @@ export interface MacInfo {
name: string name: string
model: string model: string
version: string version: string
driverVersion?: string
} }
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -33,4 +34,20 @@ export class ApplicationService extends DataService {
update () { update () {
return this.request({ method: 'GET', endpoint: '/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' })
}
} }