diff options
author | charles kerr <charlesk@canonical.com> | 2015-12-28 20:25:29 -0600 |
---|---|---|
committer | charles kerr <charlesk@canonical.com> | 2015-12-28 20:25:29 -0600 |
commit | 8b26ab8871cacd5a41bd71055054f5fa730c17b4 (patch) | |
tree | cc0d2ced6600e2b63b001c9a8e99b7965abf5448 /src/volume-warning.vala | |
parent | 206279544e63eecc480a3154053cd08323986b1a (diff) | |
download | ayatana-indicator-sound-8b26ab8871cacd5a41bd71055054f5fa730c17b4.tar.gz ayatana-indicator-sound-8b26ab8871cacd5a41bd71055054f5fa730c17b4.tar.bz2 ayatana-indicator-sound-8b26ab8871cacd5a41bd71055054f5fa730c17b4.zip |
experiment with making volume-warning's multimedia-active property protected
Diffstat (limited to 'src/volume-warning.vala')
-rw-r--r-- | src/volume-warning.vala | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/volume-warning.vala b/src/volume-warning.vala index 5d32dc4..8e38e61 100644 --- a/src/volume-warning.vala +++ b/src/volume-warning.vala @@ -23,9 +23,6 @@ using Notify; public class VolumeWarning : Object { - // true if the active sink input has its role property set to multimedia - public bool multimedia_active { get; set; default = false; } - // true if headphones are currently in use public bool headphones_active { get; set; default = false; } @@ -66,6 +63,9 @@ public class VolumeWarning : Object // true if the user has approved high volumes recently protected bool high_volume_approved { get; set; default = false; } + // true if multimedia is currently playing + protected bool multimedia_active { get; set; default = false; } + /* Cached value of what pulse says the multimedia volume is. This is a PulseAudio.Volume but typed as uint to unconfuse valac. Setting this only updates the cache -- @@ -136,10 +136,12 @@ public class VolumeWarning : Object _multimedia_sink_input_index = i.index; _multimedia_cvolume = i.volume; cached_multimedia_volume = i.volume.max(); + multimedia_active = true; } else if (i.index == _multimedia_sink_input_index) { _multimedia_sink_input_index = PulseAudio.INVALID_INDEX; cached_multimedia_volume = PulseAudio.Volume.INVALID; + multimedia_active = false; } } @@ -282,8 +284,8 @@ public class VolumeWarning : Object } private void init_high_volume() { _options.loud_changed.connect(() => update_high_volume()); - this.notify["multimedia-volume"].connect(() => { - GLib.message("recalculating high-volume due to multimedia-volume change"); + this.notify["cached-multimedia-volume"].connect(() => { + GLib.message("recalculating high-volume due to cached-multimedia-volume change"); this.update_high_volume(); }); this.notify["multimedia-active"].connect(() => { @@ -298,13 +300,12 @@ public class VolumeWarning : Object update_high_volume(); } private void update_high_volume() { - PulseAudio.Volume vol = cached_multimedia_volume; - GLib.message("calculating high volume... headphones_active %d high_volume_approved %d multimedia_active %d multimedia_volume %d is_invalid %d, is_loud %d", (int)headphones_active, (int)high_volume_approved, (int)multimedia_active, (int)vol, (int)(vol == PulseAudio.Volume.INVALID), (int)_options.is_loud_pulse(vol)); - var new_high_volume = headphones_active - && !high_volume_approved - && multimedia_active - && (vol != PulseAudio.Volume.INVALID) - && _options.is_loud_pulse(vol); + PulseAudio.Volume mm_vol = cached_multimedia_volume; + var approved = high_volume_approved; + var hp_active = headphones_active; + var mm_active = multimedia_active; + GLib.message("calculating high volume... headphones_active %d high_volume_approved %d multimedia_active %d multimedia_volume %d is_invalid %d, is_loud %d", (int)hp_active, (int)approved, (int)mm_active, (int)mm_vol, (int)(mm_vol == PulseAudio.Volume.INVALID), (int)_options.is_loud_pulse(mm_vol)); + var new_high_volume = hp_active && !approved && mm_active && (mm_vol != PulseAudio.Volume.INVALID) && _options.is_loud_pulse(mm_vol); GLib.message("so the new high_volume is %d, was %d", (int)new_high_volume, (int)high_volume); if (high_volume != new_high_volume) { debug("changing high_volume from %d to %d", (int)high_volume, (int)new_high_volume); |