diff options
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r-- | src/volume-control-pulse.vala | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index 4bd3076..6c3ef17 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -46,7 +46,6 @@ public class VolumeControlPulse : VolumeControl private VolumeControl.Volume _volume = new VolumeControl.Volume(); private double _mic_volume = 0.0; private Settings _settings = new Settings ("com.canonical.indicator.sound"); - private Settings _shared_settings = new Settings ("com.ubuntu.sound"); /* Used by the pulseaudio stream restore extension */ private DBusConnection _pconn; @@ -96,8 +95,10 @@ public class VolumeControlPulse : VolumeControl /** true when a microphone is active **/ public override bool active_mic { get; private set; default = false; } - public VolumeControlPulse () + public VolumeControlPulse (IndicatorSound.Options options) { + base(options); + _volume.volume = 0.0; _volume.reason = VolumeControl.VolumeReasons.PULSE_CHANGE; @@ -116,7 +117,6 @@ public class VolumeControlPulse : VolumeControl private void init_all_properties() { - init_max_volume(); init_high_volume(); init_high_volume_approved(); } @@ -607,13 +607,13 @@ public class VolumeControlPulse : VolumeControl } /* Volume operations */ - private static PulseAudio.Volume double_to_volume (double vol) + public static PulseAudio.Volume double_to_volume (double vol) { double tmp = (double)(PulseAudio.Volume.NORM - PulseAudio.Volume.MUTED) * vol; return (PulseAudio.Volume)tmp + PulseAudio.Volume.MUTED; } - private static double volume_to_double (PulseAudio.Volume vol) + public static double volume_to_double (PulseAudio.Volume vol) { double tmp = (double)(vol - PulseAudio.Volume.MUTED); return tmp / (double)(PulseAudio.Volume.NORM - PulseAudio.Volume.MUTED); @@ -721,30 +721,6 @@ public class VolumeControlPulse : VolumeControl } } - /** MAX VOLUME PROPERTY **/ - - private void init_max_volume() { - _settings.changed["normal-volume-decibels"].connect(() => update_max_volume()); - _settings.changed["amplified-volume-decibels"].connect(() => update_max_volume()); - _shared_settings.changed["allow-amplified-volume"].connect(() => update_max_volume()); - update_max_volume(); - } - private void update_max_volume () { - var new_max_volume = calculate_max_volume(); - if (max_volume != new_max_volume) { - debug("changing max_volume from %f to %f", this.max_volume, new_max_volume); - max_volume = calculate_max_volume(); - } - } - private double calculate_max_volume () { - unowned string decibel_key = _shared_settings.get_boolean("allow-amplified-volume") - ? "amplified-volume-decibels" - : "normal-volume-decibels"; - var volume_dB = _settings.get_double(decibel_key); - var volume_sw = PulseAudio.Volume.sw_from_dB (volume_dB); - return volume_to_double (volume_sw); - } - /** HIGH VOLUME PROPERTY **/ private bool _warning_volume_enabled; |