1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-23 06:42:02 +03:00

fix issue with volume being stuck on bluetooth & monterey

This commit is contained in:
Nodeful 2021-11-19 02:34:19 +02:00
parent 729a03d6ed
commit 9d0cfd25a4
2 changed files with 14 additions and 3 deletions

View File

@ -43,6 +43,7 @@ class Application {
static let audioPipelineIsRunning = EmitterKit.Event<Void>()
static var audioPipelineIsRunningListener: EmitterKit.EventListener<Void>?
private static var ignoreEvents = false
private static var ignoreVolumeEvents = false
static var settings: Settings!
@ -223,7 +224,10 @@ class Application {
static var ignoreNextDriverMuteEvent = false
static func setupDriverDeviceEvents () {
AudioDeviceEvents.on(.volumeChanged, onDevice: Driver.device!) {
if ignoreEvents { return }
if ignoreEvents || ignoreVolumeEvents {
return
}
if ignoreNextVolumeEvent {
ignoreNextVolumeEvent = false
return
@ -381,7 +385,9 @@ class Application {
onDevice: selectedDevice!,
retain: false
) {
if ignoreEvents { return }
if ignoreEvents || ignoreVolumeEvents {
return
}
if ignoreNextVolumeEvent {
ignoreNextVolumeEvent = false
return
@ -389,7 +395,12 @@ class Application {
let deviceVolume = selectedDevice!.virtualMasterVolume(direction: .playback)!
let driverVolume = Driver.device!.virtualMasterVolume(direction: .playback)!
if (deviceVolume != driverVolume) {
ignoreVolumeEvents = true
Driver.device!.setVirtualMasterVolume(deviceVolume, direction: .playback)
Volume.gainChanged.emit(Double(deviceVolume))
delay (50) {
ignoreVolumeEvents = false
}
}
}
audioPipelineIsRunning.emit()

View File

@ -123,7 +123,7 @@ class Volume: StoreSubscriber {
// MARK: - State
typealias StoreSubscriberStateType = VolumeState
private let changeGainThread = DispatchQueue(label: "change-volume", qos: .background)
private let changeGainThread = DispatchQueue(label: "change-volume", qos: .userInteractive)
private var latestChangeGainTask: DispatchWorkItem?
private func performOnChangeGainThread (_ code: @escaping () -> Void) {
latestChangeGainTask?.cancel()