aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/service.vala8
-rw-r--r--src/volume-control-pulse.vala29
-rw-r--r--src/volume-control.vala2
3 files changed, 17 insertions, 22 deletions
diff --git a/src/service.vala b/src/service.vala
index 25b3520..cd016c1 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -48,7 +48,7 @@ public class IndicatorSound.Service: Object {
this.volume_control = volume;
this.volume_control.active_output_changed.connect(() => {
bool headphones;
- switch(volume_control.active_output) {
+ switch(volume_control.active_output()) {
case VolumeControl.ActiveOutput.HEADPHONES:
case VolumeControl.ActiveOutput.USB_HEADPHONES:
case VolumeControl.ActiveOutput.HDMI_HEADPHONES:
@@ -252,7 +252,7 @@ public class IndicatorSound.Service: Object {
void update_root_icon () {
double volume = this.volume_control.volume.volume;
- string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_output);
+ string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_output());
string accessible_name;
if (this.volume_control.mute) {
@@ -276,7 +276,7 @@ public class IndicatorSound.Service: Object {
private bool block_info_notifications = false;
- private string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output)
+ private static string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output)
{
string icon = "";
switch (active_output)
@@ -439,7 +439,7 @@ public class IndicatorSound.Service: Object {
private void update_notification () {
if (!_volume_warning.active && !block_info_notifications) {
- _info_notification.show(this.volume_control.active_output,
+ _info_notification.show(this.volume_control.active_output(),
get_volume_percent(),
_volume_warning.high_volume);
}
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 */
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 59b3f8e..c67bbe8 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -63,7 +63,6 @@ public abstract class VolumeControl : Object
public virtual bool active_mic { get { return false; } set { } }
public virtual bool mute { get { return false; } }
public bool is_playing { get; protected set; default = false; }
- public virtual VolumeControl.ActiveOutput active_output { get { return VolumeControl.ActiveOutput.SPEAKERS; } }
private Volume _volume;
public virtual Volume volume { get { return _volume; } set { } }
public virtual double mic_volume { get { return 0.0; } set { } }
@@ -77,5 +76,6 @@ public abstract class VolumeControl : Object
this.volume = v;
}
+ public abstract VolumeControl.ActiveOutput active_output();
public signal void active_output_changed (VolumeControl.ActiveOutput active_output);
}