aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control-pulse.vala
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-01 09:55:22 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-01 09:55:22 +0200
commit33a73fad65c52fc324ad3d35a6d1305a1489958d (patch)
treed1c9058705592e5ff7b56c9e9aae6ea57b502ff7 /src/volume-control-pulse.vala
parenta7fd579fd1bc6eb02433ccd72e9f54dca2615675 (diff)
downloadayatana-indicator-sound-33a73fad65c52fc324ad3d35a6d1305a1489958d.tar.gz
ayatana-indicator-sound-33a73fad65c52fc324ad3d35a6d1305a1489958d.tar.bz2
ayatana-indicator-sound-33a73fad65c52fc324ad3d35a6d1305a1489958d.zip
Changed to show a notification when the active output changes
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r--src/volume-control-pulse.vala76
1 files changed, 42 insertions, 34 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 9edffb7..54fa18a 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -202,34 +202,38 @@ public class VolumeControlPulse : VolumeControl
this.notify_property ("is-playing");
}
- // 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);
+ // store the current status of the active output
+ VolumeControl.ActiveOutput active_output_before = active_output;
+
+ /* 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;
+ }
+
+ VolumeControl.ActiveOutput active_output_now = active_output;
+ if (active_output_now != active_output_before) {
+ this.active_output_changed (active_output_now);
+ if (active_output_now == VolumeControl.ActiveOutput.SPEAKERS) {
+ _high_volume_approved = false;
+ }
+ update_high_volume();
}
if (_pulse_use_stream_restore == false &&
@@ -552,12 +556,16 @@ public class VolumeControlPulse : VolumeControl
}
}
- public override bool active_bluetooth_headphone
- {
- get
- {
- return this._active_port_headphone_bluetooth;
- }
+ public override VolumeControl.ActiveOutput active_output
+ {
+ get
+ {
+ if (_active_port_headphone_bluetooth)
+ return VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES;
+ if (_active_port_headphone)
+ return VolumeControl.ActiveOutput.HEADPHONES;
+ return VolumeControl.ActiveOutput.SPEAKERS;
+ }
}
/* Volume operations */