Show audio muted OSD image when audio volume value is 0 (#276)

This commit is contained in:
Robert Bressi 2020-10-18 05:31:58 -07:00 committed by GitHub
parent 9e47ccfddb
commit c83fde10b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,12 @@ import DDC
import Foundation
import os.log
private enum OSDImage: Int64 {
case brightness = 1
case audioSpeaker = 3
case audioSpeakerMuted = 4
}
class Display {
internal let identifier: CGDirectDisplayID
internal let name: String
@ -48,37 +54,35 @@ class Display {
return
}
var osdImage: Int64!
var osdImage: OSDImage
switch command {
case .brightness:
osdImage = 1 // Brightness Image
case .audioSpeakerVolume:
osdImage = 3 // Speaker image
osdImage = value > 0 ? .audioSpeaker : .audioSpeakerMuted
case .audioMuteScreenBlank:
osdImage = 4 // Mute image
osdImage = .audioSpeakerMuted
default:
osdImage = 1
osdImage = .brightness
}
let filledChiclets: Int
let totalChiclets: Int
if roundChiclet {
let osdChiclet = OSDUtils.chiclet(fromValue: Float(value), maxValue: Float(maxValue))
let filledChiclets = round(osdChiclet)
manager.showImage(osdImage,
onDisplayID: self.identifier,
priority: 0x1F4,
msecUntilFade: 1000,
filledChiclets: UInt32(filledChiclets),
totalChiclets: UInt32(16),
locked: false)
filledChiclets = Int(round(osdChiclet))
totalChiclets = 16
} else {
manager.showImage(osdImage,
onDisplayID: self.identifier,
priority: 0x1F4,
msecUntilFade: 1000,
filledChiclets: UInt32(value),
totalChiclets: UInt32(maxValue),
locked: false)
filledChiclets = value
totalChiclets = maxValue
}
manager.showImage(osdImage.rawValue,
onDisplayID: self.identifier,
priority: 0x1F4,
msecUntilFade: 1000,
filledChiclets: UInt32(filledChiclets),
totalChiclets: UInt32(totalChiclets),
locked: false)
}
}