Skip to content

Commit

Permalink
ton of improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeful committed Jun 20, 2020
1 parent 2487ff7 commit 3355436
Show file tree
Hide file tree
Showing 20 changed files with 241 additions and 159 deletions.
4 changes: 2 additions & 2 deletions native/app/Embedded/eqMac.driver/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<string>1.1.0</string>
<key>CFPlugInFactories</key>
<dict>
<key>7080ba34-76cc-40b2-b2b3-819d28460e7e</key>
Expand Down
Binary file modified native/app/Embedded/eqMac.driver/Contents/MacOS/eqMac
Binary file not shown.
55 changes: 53 additions & 2 deletions native/app/Source/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SwiftyUserDefaults
import SwiftyJSON
import ServiceManagement
import ReSwift
import AudioKit
import Sparkle

enum VolumeChangeDirection: String {
Expand Down Expand Up @@ -83,6 +82,8 @@ class Application {
self.setupUI()
if (User.isFirstLaunch || Constants.DEBUG) {
UI.show()
} else {
UI.close()
}

}
Expand All @@ -108,7 +109,7 @@ class Application {
}

private static func installDriver (_ completion: @escaping() -> Void) {
if !Driver.isInstalled || Driver.isOutdated {
if !Driver.isInstalled {
Alert.confirm(
title: "Audio Driver Installation",
message: "eqMac needs to install an Audio Driver. \nIn order to do that we will ask for your System Password. \nPlease close any apps playing audio (Spotify, YouTube etc.) otherwise installation might fail.",
Expand All @@ -130,6 +131,28 @@ class Application {
quit()
}
}
} else if (Driver.isOutdated) {
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"
) { update in
if update {
Driver.install(started: {
UI.showLoadingWindow("Updating eqMac audio driver")
}) { success in
if (success) {
UI.hideLoadingWindow()
completion()
} else {
driverFailedToInstallPrompt()
}
}
} else {
completion()
}
}
} else {
completion()
}
Expand Down Expand Up @@ -490,6 +513,34 @@ class Application {
updater.checkForUpdates(nil)
}

static func reinstallDriver (_ completion: @escaping () -> 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.",
cancelText: "Cancel"
) { reinstall in
if reinstall {
Driver.install(started: {
UI.showLoadingWindow("Installing eqMac audio driver")
self.stopListeners()
self.stopEngines()
self.switchBackToLastKnownDevice()
}) { success in
if (success) {
UI.hideLoadingWindow()
setupAudio()
completion()
} else {
driverFailedToInstallPrompt()
}
}
} else {
completion()
}
}

}

static func uninstall (_ completion: @escaping (Bool) -> Void) {
Driver.uninstall(started: {
self.stopListeners()
Expand Down
33 changes: 30 additions & 3 deletions native/app/Source/Audio/Sources/System/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class Driver {
}
}

static var lastInstalledVersion: String? {
get {
return Storage[.lastInstalledDriverVersion]
}
set {
Storage[.lastInstalledDriverVersion] = newValue
}
}

static var pluginId: AudioObjectID? {
return AudioDevice.lookupIDByPluginBundleID(by: Constants.DRIVER_BUNDLE_ID)
}
Expand All @@ -47,9 +56,17 @@ class Driver {
}
}

static var info: Dictionary<String, Any> {
return NSDictionary(contentsOfFile: Bundle.main.path(forResource: "Info", ofType: "plist", inDirectory: "eqMac.driver/Contents")!) as! Dictionary<String, Any>
}

static var bundledVersion: String {
return info["CFBundleVersion"] as! String
}

static var isOutdated: Bool {
get {
return false
return bundledVersion != lastInstalledVersion
}
}

Expand Down Expand Up @@ -195,11 +212,21 @@ class Driver {
}

static func install (started: (() -> Void)? = nil, _ finished: @escaping (Bool) -> Void) {
Script.sudo("install_driver", started: started, finished)
Script.sudo("install_driver", started: started, { success in
if (success) {
lastInstalledVersion = bundledVersion
}
finished(success)
})
}

static func uninstall (started: (() -> Void)? = nil, _ finished: @escaping (Bool) -> Void) {
Script.sudo("uninstall_driver", started: started, finished)
Script.sudo("uninstall_driver", started: started, { success in
if (success) {
lastInstalledVersion = nil
}
finished(success)
})
}

}
Expand Down
29 changes: 0 additions & 29 deletions native/app/Source/Extensions/AKWorkingEqualizerFilter.swift

This file was deleted.

1 change: 1 addition & 0 deletions native/app/Source/Extensions/AudioDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extension AudioDevice {
mElement: kAudioObjectPropertyElementMaster)
var value = AudioValueRange(mMinimum: 0, mMaximum: 0)
// Try master first

if checkErr(AudioDevice.getPropertyData(self.id, address: propertyAddress, andValue: &value)) != nil {
propertyAddress.mElement = 1
// Try single channel
Expand Down
2 changes: 1 addition & 1 deletion native/app/Source/Helpers/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension DefaultsKeys {

// Effects - Equalizer - Advanced
static let advancedEqualizerPresets = DefaultsKey<[AdvancedEqualizerPreset]?>("advancedEqualizerPresets")

static let lastInstalledDriverVersion = DefaultsKey<String?>("lastInstalledDriverVersion")
}

let Storage = Defaults
Expand Down
2 changes: 1 addition & 1 deletion native/app/Source/Scripts/install_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ touch /Library/Extensions &>/dev/null || true

# Copy driver into Plug-Ins folder
cp -f -r "$DIR/eqMac.driver" /Library/Audio/Plug-Ins/HAL/ ||
cp -f -r "../../../build/eqMac/Build/Products/Release/eqMac.driver" /Library/Audio/Plug-Ins/HAL/ # if running from terminal
cp -f -r "../../Embedded/eqMac.driver" /Library/Audio/Plug-Ins/HAL/ # if running from terminal

# Restart CoreAudio
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
Expand Down
2 changes: 1 addition & 1 deletion native/app/Source/UI/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.isOneShot = true
self.titleVisibility = .hidden
self.titlebarAppearsTransparent = true
self.isMovableByWindowBackground = true
Expand Down
4 changes: 0 additions & 4 deletions native/app/eqMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
E02FF91622C7EC6C0051342A /* Transition.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02FF91522C7EC6C0051342A /* Transition.swift */; };
E02FF91822C8E87D0051342A /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02FF91722C8E87D0051342A /* Time.swift */; };
E02FF91A22C95B310051342A /* TransitionDataBus.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02FF91922C95B310051342A /* TransitionDataBus.swift */; };
E030FDB4211F766100BA524E /* AKWorkingEqualizerFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E030FDB3211F766100BA524E /* AKWorkingEqualizerFilter.swift */; };
E031E9CE23700DDF00BA6DD8 /* Outputs.swift in Sources */ = {isa = PBXBuildFile; fileRef = E031E9CD23700DDF00BA6DD8 /* Outputs.swift */; };
E036BCE723598772001F057B /* DataBus.swift in Sources */ = {isa = PBXBuildFile; fileRef = E036BCE623598772001F057B /* DataBus.swift */; };
E036BCEA235B1171001F057B /* ApplicationDataBus.swift in Sources */ = {isa = PBXBuildFile; fileRef = E036BCE9235B1171001F057B /* ApplicationDataBus.swift */; };
Expand Down Expand Up @@ -158,7 +157,6 @@
E02FF91522C7EC6C0051342A /* Transition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transition.swift; sourceTree = "<group>"; };
E02FF91722C8E87D0051342A /* Time.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Time.swift; sourceTree = "<group>"; };
E02FF91922C95B310051342A /* TransitionDataBus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransitionDataBus.swift; sourceTree = "<group>"; };
E030FDB3211F766100BA524E /* AKWorkingEqualizerFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AKWorkingEqualizerFilter.swift; sourceTree = "<group>"; };
E031E9CD23700DDF00BA6DD8 /* Outputs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Outputs.swift; sourceTree = "<group>"; };
E036BCE623598772001F057B /* DataBus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataBus.swift; sourceTree = "<group>"; };
E036BCE9235B1171001F057B /* ApplicationDataBus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationDataBus.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -263,7 +261,6 @@
isa = PBXGroup;
children = (
E00C595C23BBBB6C00C7B8B6 /* UnsafeMutableAudioBufferListPointer.swift */,
E030FDB3211F766100BA524E /* AKWorkingEqualizerFilter.swift */,
E01F2F5E2034A188005123BE /* ArrayExtensions.swift */,
E07A24E31FF3D49F007AEF20 /* AudioDevice.swift */,
E07B45A520FBA4990086AA7E /* Encodable.swift */,
Expand Down Expand Up @@ -833,7 +830,6 @@
files = (
E00C596623BBBF3100C7B8B6 /* Atomic.m in Sources */,
E089AC492095E0B1005B72E5 /* Console.swift in Sources */,
E030FDB4211F766100BA524E /* AKWorkingEqualizerFilter.swift in Sources */,
E0AAD9DA249C109000D58099 /* SwiftyPing.swift in Sources */,
E090AD5820A9725F003BE5FF /* Volume.swift in Sources */,
E073727D20167E7600874CC6 /* Application.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions native/driver/Driver.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = JZA6C97KJA;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
Expand All @@ -609,6 +610,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL";
MARKETING_VERSION = 1.1.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.bitgapp.eqmac.driver;
Expand All @@ -635,6 +637,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = JZA6C97KJA;
ENABLE_NS_ASSERTIONS = NO;
Expand All @@ -647,6 +650,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL";
MARKETING_VERSION = 1.1.0;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.bitgapp.eqmac.driver;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
2 changes: 1 addition & 1 deletion native/driver/Scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# Type a script or drag a script file from your workspace to insert its path.
if [ "${CONFIGURATION}" = "Release" ]; then
cp -r "$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME" "$SRCROOT/../app/Embedded/$FULL_PRODUCT_NAME"
cp -r "$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME" "$SRCROOT/../app/Embedded/"
fi

if [ "${CONFIGURATION}" = "Debug" ]; then
Expand Down
Loading

0 comments on commit 3355436

Please sign in to comment.