mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Volume control now mutes completely
This commit is contained in:
parent
106f431682
commit
ff3bdde7d3
1 changed files with 8 additions and 1 deletions
|
|
@ -52,6 +52,7 @@ final class SystemVolumeController {
|
|||
private var listenersInstalled = false
|
||||
private var volumeElement: AudioObjectPropertyElement?
|
||||
private var muteElement: AudioObjectPropertyElement?
|
||||
private let silenceThreshold: Float = 0.001 // Treat very low values as mute requests.
|
||||
|
||||
private let candidateElements: [AudioObjectPropertyElement] = [
|
||||
kAudioObjectPropertyElementMain,
|
||||
|
|
@ -101,7 +102,13 @@ final class SystemVolumeController {
|
|||
|
||||
func setVolume(_ value: Float) {
|
||||
let clamped = max(0, min(1, value))
|
||||
if isMuted && clamped > 0 {
|
||||
let currentlyMuted = isMuted
|
||||
|
||||
if clamped <= silenceThreshold {
|
||||
if !currentlyMuted {
|
||||
setMuted(true)
|
||||
}
|
||||
} else if currentlyMuted {
|
||||
setMuted(false)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue