aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control-pulse.vala
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-11-23 12:30:01 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-11-23 12:30:01 +0100
commit9da17031233db5f7961f3dd7be69c8a3bc13bb27 (patch)
tree1a478b3b7767b8783037a94c4a9283bb6a889765 /src/volume-control-pulse.vala
parentd7fa04a96f2d9eabfdcc56574895c0c9f5785231 (diff)
downloadayatana-indicator-sound-9da17031233db5f7961f3dd7be69c8a3bc13bb27.tar.gz
ayatana-indicator-sound-9da17031233db5f7961f3dd7be69c8a3bc13bb27.tar.bz2
ayatana-indicator-sound-9da17031233db5f7961f3dd7be69c8a3bc13bb27.zip
Added a CALL mode and avoid sending output notifications when we have an incoming call
Diffstat (limited to 'src/volume-control-pulse.vala')
-rw-r--r--src/volume-control-pulse.vala51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 83b10d5..66b6ba4 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -140,40 +140,45 @@ public class VolumeControlPulse : VolumeControl
VolumeControl.ActiveOutput ret_output = VolumeControl.ActiveOutput.SPEAKERS;
/* 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' */
+ /* 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' */
+
+ // first of all check if we are in call mode
+ if (sink.active_port != null && sink.active_port.name == "output-speaker+wired_headphone") {
+ return VolumeControl.ActiveOutput.CALL_MODE;
+ }
// look if it's a headset/headphones
if (sink.name == "indicator_sound_test_headphones" ||
(sink.active_port != null &&
(sink.active_port.name.contains("headset") ||
- sink.active_port.name.contains("headphone")))) {
- _active_port_headphone = true;
- // check if it's a bluetooth device
- var device_bus = sink.proplist.gets ("device.bus");
- if (device_bus != null && device_bus == "bluetooth") {
- ret_output = VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES;
- } else if (device_bus != null && device_bus == "usb") {
- ret_output = VolumeControl.ActiveOutput.USB_HEADPHONES;
- } else if (device_bus != null && device_bus == "hdmi") {
- ret_output = VolumeControl.ActiveOutput.HDMI_HEADPHONES;
- } else {
- ret_output = VolumeControl.ActiveOutput.HEADPHONES;
- }
+ sink.active_port.name.contains("headphone")))) {
+ _active_port_headphone = true;
+ // check if it's a bluetooth device
+ var device_bus = sink.proplist.gets ("device.bus");
+ if (device_bus != null && device_bus == "bluetooth") {
+ ret_output = VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES;
+ } else if (device_bus != null && device_bus == "usb") {
+ ret_output = VolumeControl.ActiveOutput.USB_HEADPHONES;
+ } else if (device_bus != null && device_bus == "hdmi") {
+ ret_output = VolumeControl.ActiveOutput.HDMI_HEADPHONES;
+ } else {
+ ret_output = VolumeControl.ActiveOutput.HEADPHONES;
+ }
} else {
// speaker
_active_port_headphone = false;
var device_bus = sink.proplist.gets ("device.bus");
- if (device_bus != null && device_bus == "bluetooth") {
- ret_output = VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER;
- } else if (device_bus != null && device_bus == "usb") {
+ if (device_bus != null && device_bus == "bluetooth") {
+ ret_output = VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER;
+ } else if (device_bus != null && device_bus == "usb") {
ret_output = VolumeControl.ActiveOutput.USB_SPEAKER;
} else if (device_bus != null && device_bus == "hdmi") {
ret_output = VolumeControl.ActiveOutput.HDMI_SPEAKER;
} else {
ret_output = VolumeControl.ActiveOutput.SPEAKERS;
- }
+ }
}
return ret_output;
@@ -253,7 +258,9 @@ public class VolumeControlPulse : VolumeControl
// 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) {
+ 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);
if (active_output_now == VolumeControl.ActiveOutput.SPEAKERS) {
_high_volume_approved = false;