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

fixed bluetooth going into headset mode on quit

This commit is contained in:
Nodeful 2021-07-11 20:49:01 +03:00
parent f7f9122bb4
commit 380f61e975
32 changed files with 46 additions and 101 deletions

View File

@ -275,12 +275,15 @@ class Application {
return
}
var volume: Double = Application.store.state.effects.volume.gain
if (AudioDevice.currentOutputDevice.outputVolumeSupported) {
volume = Double(AudioDevice.currentOutputDevice.virtualMasterVolume(direction: .playback)!)
var muted = store.state.effects.volume.muted
if (selectedDevice!.outputVolumeSupported) {
volume = Double(selectedDevice!.virtualMasterVolume(direction: .playback)!)
muted = selectedDevice!.mute
}
Application.dispatchAction(VolumeAction.setGain(volume, false))
Application.dispatchAction(VolumeAction.setBalance(Application.store.state.effects.volume.balance, false))
Application.dispatchAction(VolumeAction.setMuted(muted))
Driver.device!.setVirtualMasterVolume(volume > 1 ? 1 : Float32(volume), direction: .playback)
Driver.latency = selectedDevice!.latency(direction: .playback) ?? 0 // Set driver latency to mimic device
@ -441,10 +444,10 @@ class Application {
}
static func stopSave () {
stopListeners()
switchBackToLastKnownDevice()
stopRemoveEngines()
Storage.synchronize()
stopListeners()
stopRemoveEngines()
switchBackToLastKnownDevice()
}
static func handleSleep () {

View File

@ -68,30 +68,27 @@ class Volume: StoreSubscriber {
}
mixer.outputVolume = Float(virtualVolume)
if (!volumeSupported) {
Driver.device!.mute = false
device.mute = false
}
let shouldMute = gain == 0.0
Driver.device!.mute = shouldMute
device.mute = shouldMute
Volume.gainChanged.emit(gain)
Application.ignoreNextVolumeEvent = false
Application.ignoreNextDriverMuteEvent = false
if (gain == 0) {
Application.dispatchAction(VolumeAction.setMuted(true))
} else if (muted) {
Application.dispatchAction(VolumeAction.setMuted(false))
}
}
}
var muted: Bool = false {
didSet {
Driver.device!.mute = muted
Application.selectedDevice!.mute = muted
if (muted) {
mixer.outputVolume = 0
} else {
(gain = gain)
}
Application.ignoreNextDriverMuteEvent = false
Volume.mutedChanged.emit(muted)
}
}
@ -175,6 +172,9 @@ class Volume: StoreSubscriber {
Console.log("Creating Volume")
({
self.boostEnabled = state.boostEnabled
self.balance = state.balance
self.gain = state.gain
self.muted = state.muted
})()
setupStateListener()
}

View File

@ -29,7 +29,7 @@ class StatusItem {
}
}
private static let iconSize = NSMakeSize(20, 15)
private static let iconSize = NSMakeSize(20, 14)
private static let speakerIconImages: [NSImage] = [
NSImage(named: "speaker0")!.resize(with: iconSize),
NSImage(named: "speaker1")!.resize(with: iconSize),
@ -37,8 +37,8 @@ class StatusItem {
NSImage(named: "speaker3")!.resize(with: iconSize)
]
private static let classicIconImage = NSImage(named: "statusBarIcon")!.resize(with: NSMakeSize(20, 20))
static func getNativeImageForVolume (_ volume: Double) -> NSImage {
if volume <= 0.01 {
static func getNativeImageFor (volume: Double, muted: Bool) -> NSImage {
if muted || volume <= 0.01 {
return speakerIconImages[0]
}
if volume <= 0.33 {
@ -63,7 +63,10 @@ class StatusItem {
image.isTemplate = false
break
case .macOS:
image = StatusItem.getNativeImageForVolume(Application.store.state.effects.volume.gain)
image = StatusItem.getNativeImageFor(
volume: Application.store.state.effects.volume.gain,
muted: Application.store.state.effects.volume.muted
)
image.isTemplate = true
break
}
@ -78,6 +81,7 @@ class StatusItem {
private let rightClickMenu = NSMenu()
let rightClickGesture = NSClickGestureRecognizer()
private var volumeGainChangedListener: EventListener<Double>!
private var mutedChangedListener: EventListener<Bool>!
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
var button: NSStatusBarButton!
@ -86,7 +90,12 @@ class StatusItem {
public init() {
self.button = item.button!
// Listen to volume changes and apply icon
self.volumeGainChangedListener = Volume.gainChanged.on { [weak self] gain in
self.volumeGainChangedListener = Volume.gainChanged.on { [weak self] _ in
if (self != nil && self!.iconType == .macOS) {
(self!.iconType = self!.iconType)
}
}
self.mutedChangedListener = Volume.mutedChanged.on { [weak self] _ in
if (self != nil && self!.iconType == .macOS) {
(self!.iconType = self!.iconType)
}

View File

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2743C9C51D7EF84B0089613B"
BuildableName = "libPublicUtility.a"
BlueprintName = "PublicUtility"
ReferencedContainer = "container:Driver.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2743C9C51D7EF84B0089613B"
BuildableName = "libPublicUtility.a"
BlueprintName = "PublicUtility"
ReferencedContainer = "container:Driver.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "speaker0-66.png",
"filename" : "0-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "speaker0-65.png",
"filename" : "0-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "speaker0-64.png",
"filename" : "0.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "speaker1-66.png",
"filename" : "1-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "speaker1-65.png",
"filename" : "1-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "speaker1-64.png",
"filename" : "1.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "speaker2-66.png",
"filename" : "2-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "speaker2-65.png",
"filename" : "2-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "speaker2-64.png",
"filename" : "2.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,17 +1,17 @@
{
"images" : [
{
"filename" : "speaker3-66.png",
"filename" : "3-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "speaker3-65.png",
"filename" : "3-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "speaker3-64.png",
"filename" : "3.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB