Skip to content

Commit ce684e5

Browse files
committed
Improved volume handling
1 parent d4acbfe commit ce684e5

6 files changed

Lines changed: 32 additions & 7 deletions

File tree

native/app/Embedded/ui.zip

-1 Bytes
Binary file not shown.

native/app/Source/Application.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ class Application {
251251
setupDriverDeviceEvents()
252252
}
253253

254+
private static var ignoreNextDriverMuteEvent = false
254255
private static func setupDriverDeviceEvents () {
255256
AudioDeviceEvents.on(.volumeChanged, onDevice: Driver.device!) {
256257
if ignoreNextVolumeEvent {
@@ -264,11 +265,17 @@ class Application {
264265
return
265266
}
266267
let gain = Double(Driver.device!.virtualMasterVolume(direction: .playback)!)
268+
Console.log(gain)
267269
if (gain <= 1 && gain != Application.store.state.effects.volume.gain) {
268270
Application.dispatchAction(VolumeAction.setGain(gain, false))
269271
}
270272
}
273+
271274
AudioDeviceEvents.on(.muteChanged, onDevice: Driver.device!) {
275+
if (ignoreNextDriverMuteEvent) {
276+
ignoreNextDriverMuteEvent = false
277+
return
278+
}
272279
Application.dispatchAction(VolumeAction.setMuted(Driver.device!.mute))
273280
}
274281
}
@@ -395,6 +402,12 @@ class Application {
395402

396403
static var overrideNextVolumeEvent = false
397404
static func volumeChangeButtonPressed (direction: VolumeChangeDirection, quarterStep: Bool = false) {
405+
if direction == .UP {
406+
ignoreNextDriverMuteEvent = true
407+
Utilities.delay(100) {
408+
ignoreNextDriverMuteEvent = false
409+
}
410+
}
398411
let gain = volume.gain
399412
if (gain >= 1) {
400413
if direction == .DOWN {
@@ -426,6 +439,10 @@ class Application {
426439
}
427440
}
428441

442+
static func muteButtonPressed () {
443+
ignoreNextDriverMuteEvent = false
444+
}
445+
429446
private static func killEngine () {
430447
engine = nil
431448
}

native/app/Source/Audio/Volume/Volume.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Volume: StoreSubscriber {
1717
var gainChanged = EmitterKit.Event<Double>()
1818
var balanceChanged = EmitterKit.Event<Double>()
1919
var mutedChanged = EmitterKit.Event<Bool>()
20-
20+
2121
// MARK: - Properties
2222
var gain: Double = 1 {
2323
didSet {
@@ -72,14 +72,23 @@ class Volume: StoreSubscriber {
7272
newRightGain = gain * Utilities.mapValue(value: Double(balance), inMin: 0, inMax: -1, outMin: 1, outMax: 0)
7373
}
7474
}
75-
75+
7676
Driver.device!.setVirtualMasterVolume(Float32(gain), direction: .playback)
7777
}
7878

7979
leftGain = newLeftGain
8080
rightGain = newRightGain
81-
Driver.device!.mute = false
82-
device.mute = false
81+
82+
if (!volumeSupported) {
83+
Driver.device!.mute = false
84+
device.mute = false
85+
}
86+
87+
let shouldMute = gain == 0.0
88+
Driver.device!.mute = shouldMute
89+
device.mute = shouldMute
90+
91+
8392
gainChanged.emit(gain)
8493

8594
}

native/app/Source/EventInterceptor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class EventInterceptor: NSApplication {
2828
Application.volumeChangeButtonPressed(direction: .DOWN, quarterStep: shiftPressed(event: event) && optionPressed(event: event))
2929
return
3030
case NX_KEYTYPE_MUTE:
31-
// Application.toggleMute()
31+
Application.muteButtonPressed()
3232
return
3333
default: break
3434
}

native/app/Source/Extensions/AudioDevice.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ extension AudioDevice {
6060
if (self.canMuteVirtualMasterChannel(direction: .playback)) {
6161
self.setMute(newValue, channel: 0, direction: .playback)
6262
} else {
63-
Console.log(self.channels(direction: .playback).intValue)
6463
let channels = self.channels(direction: .playback).intValue
6564
if channels >= 1 {
6665
for channel in 1...self.channels(direction: .playback).intValue {

ui/src/app/modules/eqmac-components/components/icon/icon.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
1111
selector: 'eqm-icon',
1212
templateUrl: './icon.component.html',
1313
styleUrls: ['./icon.component.scss'],
14-
encapsulation: ViewEncapsulation.None
14+
encapsulation: ViewEncapsulation.ShadowDom
1515
})
1616
export class IconComponent implements OnInit {
1717
@Input() width = 20

0 commit comments

Comments
 (0)