aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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; } }