diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2015-08-11 15:10:56 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2015-08-11 15:10:56 -0500 |
commit | f52fe2483aae720b92878272f052b8fc6605dcd9 (patch) | |
tree | 482b18696c6f7bfb99582cfcc32c16ca47be17e5 /src/volume-control-pulse.vala | |
parent | 8e7aa6d1ba5f62c4525c7d20e674ce8ef579040b (diff) | |
download | ayatana-indicator-sound-f52fe2483aae720b92878272f052b8fc6605dcd9.tar.gz ayatana-indicator-sound-f52fe2483aae720b92878272f052b8fc6605dcd9.tar.bz2 ayatana-indicator-sound-f52fe2483aae720b92878272f052b8fc6605dcd9.zip |
clamp the volume whenever the 'high volume' confirmation notification is open.
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r-- | src/volume-control-pulse.vala | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index 7f0edcb..edbfd23 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -616,16 +616,6 @@ public class VolumeControlPulse : VolumeControl return _volume; } set { - - if ((value.reason == VolumeReasons.USER_KEYPRESS) - && !_high_volume_approved - && calculate_high_volume_from_volume(value.volume)) - { - var clamped = value.volume.clamp(0, _warning_volume_norms); - message("User is trying to raise volume past warning... clamping from %f down to %f", value.volume, clamped); - value.volume = clamped; - } - var volume_changed = (value.volume != _volume.volume); debug("Setting volume to %f for profile %d because %d", value.volume, _active_sink_input, value.reason); @@ -722,6 +712,19 @@ public class VolumeControlPulse : VolumeControl && (stream == "multimedia"); } + public override void clamp_to_high_volume() { + if (_high_volume) { + message("_volume.volume(%f) _warning_volume_norms(%f)", _volume.volume, _warning_volume_norms); + if (_volume.volume > _warning_volume_norms) { + var vol = new VolumeControl.Volume(); + vol.volume = _volume.volume.clamp(0, _warning_volume_norms); + vol.reason = _volume.reason; + message("Clamping from %f down to %f", _volume.volume, vol.volume); + volume = vol; + } + } + } + /** HIGH VOLUME APPROVED PROPERTY **/ private bool _high_volume_approved = false; |