diff options
author | charles kerr <charlesk@canonical.com> | 2015-12-30 17:23:18 -0600 |
---|---|---|
committer | charles kerr <charlesk@canonical.com> | 2015-12-30 17:23:18 -0600 |
commit | 462abafeb9286aa91fdc11bd789914add4db6ca9 (patch) | |
tree | 1b40600d16f7cd3eeb15a266d0d088a77d9f3b75 /src/volume-control-pulse.vala | |
parent | bf558d1150e8ed346c659056ad4c18cbc26b8daa (diff) | |
download | ayatana-indicator-sound-462abafeb9286aa91fdc11bd789914add4db6ca9.tar.gz ayatana-indicator-sound-462abafeb9286aa91fdc11bd789914add4db6ca9.tar.bz2 ayatana-indicator-sound-462abafeb9286aa91fdc11bd789914add4db6ca9.zip |
make VolumeControl::active_output easier to mock for tests
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r-- | src/volume-control-pulse.vala | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index d8b9520..74ef015 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -209,18 +209,16 @@ public class VolumeControlPulse : VolumeControl if (is_playing != playing) is_playing = playing; - // store the current status of the active output - VolumeControl.ActiveOutput active_output_before = active_output; + var oldval = _active_output; + var newval = calculate_active_output(i); - // calculate the output - _active_output = calculate_active_output (i); - - // check if the output has changed, if so... emit a signal - VolumeControl.ActiveOutput active_output_now = active_output; - if (active_output_now != active_output_before && - (active_output_now != VolumeControl.ActiveOutput.CALL_MODE && - active_output_before != VolumeControl.ActiveOutput.CALL_MODE)) { - this.active_output_changed (active_output_now); + _active_output = newval; + + // Emit a change signal iff CALL_MODE wasn't involved. (FIXME: yuck.) + if ((oldval != VolumeControl.ActiveOutput.CALL_MODE) && + (newval != VolumeControl.ActiveOutput.CALL_MODE) && + (oldval != newval)) { + this.active_output_changed (newval); } if (_pulse_use_stream_restore == false && @@ -555,12 +553,9 @@ public class VolumeControlPulse : VolumeControl } } - public override VolumeControl.ActiveOutput active_output - { - get - { - return _active_output; - } + public override VolumeControl.ActiveOutput active_output() + { + return _active_output; } /* Volume operations */ |