aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2015-12-20 15:42:57 -0600
committercharles kerr <charlesk@canonical.com>2015-12-20 15:42:57 -0600
commit60cd7ac64849bfc21be1a85063f5730ad22f9d72 (patch)
tree33adcf048e6be17c500c2fef2ca8ac4aa37245e8 /src
parent2fedb182f5321d381821178ce10dd395113ab11b (diff)
downloadayatana-indicator-sound-60cd7ac64849bfc21be1a85063f5730ad22f9d72.tar.gz
ayatana-indicator-sound-60cd7ac64849bfc21be1a85063f5730ad22f9d72.tar.bz2
ayatana-indicator-sound-60cd7ac64849bfc21be1a85063f5730ad22f9d72.zip
always keep volume-control's 'stream' property updated
Diffstat (limited to 'src')
-rw-r--r--src/volume-control-pulse.vala32
-rw-r--r--src/volume-control.vala9
2 files changed, 24 insertions, 17 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index fae113d..a5d3baf 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -53,22 +53,6 @@ public class VolumeControlPulse : VolumeControl
private bool _pulse_use_stream_restore = false;
private int32 _active_sink_input = -1;
private string[] _valid_roles = {"multimedia", "alert", "alarm", "phone"};
- public override string stream {
- get {
- if (_active_sink_input == -1)
- return "alert";
- var path = _sink_input_hash[_active_sink_input];
- if (path == _objp_role_multimedia)
- return "multimedia";
- if (path == _objp_role_alert)
- return "alert";
- if (path == _objp_role_alarm)
- return "alarm";
- if (path == _objp_role_phone)
- return "phone";
- return "alert";
- }
- }
private string? _objp_role_multimedia = null;
private string? _objp_role_alert = null;
private string? _objp_role_alarm = null;
@@ -329,6 +313,21 @@ public class VolumeControlPulse : VolumeControl
return message;
}
+ private VolumeControl.Stream calculate_active_stream()
+ {
+ if (_active_sink_input != -1) {
+ var path = _sink_input_hash[_active_sink_input];
+ if (path == _objp_role_multimedia)
+ return Stream.MULTIMEDIA;
+ if (path == _objp_role_alarm)
+ return Stream.ALARM;
+ if (path == _objp_role_phone)
+ return Stream.PHONE;
+ }
+
+ return VolumeControl.Stream.ALERT;
+ }
+
private async void update_active_sink_input (int32 index)
{
if ((index == -1) || (index != _active_sink_input && index in _sink_input_list)) {
@@ -336,6 +335,7 @@ public class VolumeControlPulse : VolumeControl
if (index != -1)
sink_input_objp = _sink_input_hash.get (index);
_active_sink_input = index;
+ active_stream = calculate_active_stream();
/* Listen for role volume changes from pulse itself (external clients) */
try {
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 53e4336..d13bf31 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -40,6 +40,13 @@ public abstract class VolumeControl : Object
CALL_MODE
}
+ public enum Stream {
+ ALERT,
+ MULTIMEDIA,
+ ALARM,
+ PHONE
+ }
+
public class Volume : Object {
public double volume;
public VolumeReasons reason;
@@ -51,7 +58,7 @@ public abstract class VolumeControl : Object
_options = options;
}
- public virtual string stream { get { return ""; } }
+ public Stream active_stream { get; protected set; default = Stream.ALERT; }
public bool ready { get; protected set; default = false; }
public virtual bool active_mic { get { return false; } set { } }
public virtual bool mute { get { return false; } }