aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control-pulse.vala
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-29 14:13:45 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-29 14:13:45 +0200
commita7fd579fd1bc6eb02433ccd72e9f54dca2615675 (patch)
tree43892b38a791ff60f31cbd10041539a6fcf245ba /src/volume-control-pulse.vala
parent918c9b9a95573b0dfe0e2e67ef30b998b5576e82 (diff)
downloadayatana-indicator-sound-a7fd579fd1bc6eb02433ccd72e9f54dca2615675.tar.gz
ayatana-indicator-sound-a7fd579fd1bc6eb02433ccd72e9f54dca2615675.tar.bz2
ayatana-indicator-sound-a7fd579fd1bc6eb02433ccd72e9f54dca2615675.zip
Adding the code to change the icons and label when a bluetooth headset is connected
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r--src/volume-control-pulse.vala49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 87af258..9edffb7 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -87,6 +87,7 @@ public class VolumeControlPulse : VolumeControl
private bool _send_next_local_volume = false;
private double _account_service_volume = 0.0;
private bool _active_port_headphone = false;
+ private bool _active_port_headphone_bluetooth = false;
/** true when connected to the pulse server */
public override bool ready { get; private set; }
@@ -201,18 +202,34 @@ public class VolumeControlPulse : VolumeControl
this.notify_property ("is-playing");
}
- /* Check if the current active port is headset/headphone */
- /* There is not easy way to check if the port is a headset/headphone besides
- * checking for the port name. On touch (with the pulseaudio droid element)
- * the headset/headphone port is called 'output-headset' and 'output-headphone'.
- * On the desktop this is usually called 'analog-output-headphones' */
- if (i.active_port != null &&
- (i.active_port.name == "output-wired_headset" ||
- i.active_port.name == "output-wired_headphone" ||
- i.active_port.name == "analog-output-headphones")) {
- _active_port_headphone = true;
- } else {
- _active_port_headphone = false;
+ // store the current status of the bluetooth headset
+ // if it changes we'll emit a signal
+ bool active_port_headphone_bluetooth_before = _active_port_headphone_bluetooth;
+
+ /* Check if the current active port is headset/headphone */
+ /* There is not easy way to check if the port is a headset/headphone besides
+ * checking for the port name. On touch (with the pulseaudio droid element)
+ * the headset/headphone port is called 'output-headset' and 'output-headphone'.
+ * On the desktop this is usually called 'analog-output-headphones' */
+ if (i.active_port != null &&
+ (i.active_port.name.contains("headset") ||
+ i.active_port.name.contains("headphone"))) {
+ _active_port_headphone = true;
+ // check if it's a bluetooth device
+ var device_bus = i.proplist.gets ("device.bus");
+ if (device_bus != null && device_bus == "bluetooth") {
+ _active_port_headphone_bluetooth = true;
+
+ } else {
+ _active_port_headphone_bluetooth = false;
+ }
+ } else {
+ _active_port_headphone = false;
+ _active_port_headphone_bluetooth = false;
+ }
+
+ if (_active_port_headphone_bluetooth != active_port_headphone_bluetooth_before) {
+ this.bluetooth_headset_status_changed (_active_port_headphone_bluetooth);
}
if (_pulse_use_stream_restore == false &&
@@ -535,6 +552,14 @@ public class VolumeControlPulse : VolumeControl
}
}
+ public override bool active_bluetooth_headphone
+ {
+ get
+ {
+ return this._active_port_headphone_bluetooth;
+ }
+ }
+
/* Volume operations */
private static PulseAudio.Volume double_to_volume (double vol)
{