Skip to content

Commit

Permalink
build 9, attempt to fix #32
Browse files Browse the repository at this point in the history
Test implementation.

Explicitly select the device that you want to playback (not the auto "default device" selection). Check if device will continue to stick to your selected device, even in circumstances such as EQ / virtual device.

App device selection menu may glitch out showing 2 checkmarks on app restart, but that is expected, cosmetic behaviour.
  • Loading branch information
vincentneo committed Nov 16, 2022
1 parent e7aedc9 commit ac33688
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Quality.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
CODE_SIGN_ENTITLEMENTS = Quality/Quality.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_ASSET_PATHS = "\"Quality/Preview Content\"";
DEVELOPMENT_TEAM = 3X69W4AQD6;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -372,7 +372,7 @@
CODE_SIGN_ENTITLEMENTS = Quality/Quality.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 9;
DEVELOPMENT_ASSET_PATHS = "\"Quality/Preview Content\"";
DEVELOPMENT_TEAM = 3X69W4AQD6;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
9 changes: 8 additions & 1 deletion Quality/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {

var idx = 0
for device in outputDevices.outputDevices {
let uid = device.uid
let name = device.name
let item = DeviceMenuItem(title: name, action: #selector(deviceSelection(_:)), keyEquivalent: "", device: device)
item.tag = idx
item.state = .off
if let uid, uid == Defaults.shared.selectedDeviceUID {
item.state = .on
}
else {
item.state = .off
}
idx += 1
self.devicesMenu.addItem(item)
}
Expand All @@ -129,6 +135,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self.devicesMenu.items.forEach({$0.state = .off})
sender.state = .on
outputDevices.selectedOutputDevice = sender.device
Defaults.shared.selectedDeviceUID = sender.device?.uid
}

func statusItemDisplay() {
Expand Down
10 changes: 10 additions & 0 deletions Quality/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
class Defaults {
static let shared = Defaults()
private let kUserPreferIconStatusBarItem = "com.vincent-neo.LosslessSwitcher-Key-UserPreferIconStatusBarItem"
private let kSelectedDeviceUID = "com.vincent-neo.LosslessSwitcher-Key-SelectedDeviceUID"

private init() {
UserDefaults.standard.register(defaults: [kUserPreferIconStatusBarItem : true])
Expand All @@ -24,6 +25,15 @@ class Defaults {
}
}

var selectedDeviceUID: String? {
get {
return UserDefaults.standard.string(forKey: kSelectedDeviceUID)
}
set {
UserDefaults.standard.set(newValue, forKey: kSelectedDeviceUID)
}
}

var statusBarItemTitle: String {
let title = self.userPreferIconStatusBarItem ? "Show Sample Rate" : "Show Icon"
return title
Expand Down

0 comments on commit ac33688

Please sign in to comment.