aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-03 13:40:53 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-03 13:40:53 +0100
commit19d447425a8eaee64291ce1667d82506de065756 (patch)
treeee35d013eb812962d91918a65b58f05e11aec743 /src
parent3aa67455801c7db139be5a9293ddb6d7d703a981 (diff)
downloadayatana-indicator-sound-19d447425a8eaee64291ce1667d82506de065756.tar.gz
ayatana-indicator-sound-19d447425a8eaee64291ce1667d82506de065756.tar.bz2
ayatana-indicator-sound-19d447425a8eaee64291ce1667d82506de065756.zip
Changes to show up the microphone volume control when an external mic is detected
Diffstat (limited to 'src')
-rw-r--r--src/volume-control-pulse.vala22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index c8a6071..92f12a3 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -54,6 +54,8 @@ public class VolumeControlPulse : VolumeControl
private double _account_service_volume = 0.0;
private VolumeControl.ActiveOutput _active_output = VolumeControl.ActiveOutput.SPEAKERS;
private AccountsServiceAccess _accounts_service_access;
+ private bool _external_mic_detected = false;
+ private bool _source_sink_mic_activated = false;
/** true when a microphone is active **/
public override bool active_mic { get; private set; default = false; }
@@ -180,7 +182,8 @@ public class VolumeControlPulse : VolumeControl
break;
case Context.SubscriptionEventType.REMOVE:
- this.active_mic = false;
+ this._source_sink_mic_activated = false;
+ this.active_mic = _external_mic_detected;
break;
}
break;
@@ -229,6 +232,19 @@ public class VolumeControlPulse : VolumeControl
if (i == null)
return;
+ if (i.active_port != null &&
+ ( (i.active_port.name.contains ("headphone") ||
+ i.active_port.name.contains ("headset") ||
+ i.active_port.name.contains ("mic") ) &&
+ (!i.active_port.name.contains ("internal") &&
+ !i.active_port.name.contains ("builtin")) )) {
+ this.active_mic = true;
+ _external_mic_detected = true;
+ } else {
+ this.active_mic = _source_sink_mic_activated;
+ _external_mic_detected = false;
+ }
+
if (_mic_volume != volume_to_double (i.volume.values[0]))
{
_mic_volume = volume_to_double (i.volume.values[0]);
@@ -434,8 +450,10 @@ public class VolumeControlPulse : VolumeControl
return;
unowned string role = i.proplist.gets (PulseAudio.Proplist.PROP_MEDIA_ROLE);
- if (role == "phone" || role == "production")
+ if (role == "phone" || role == "production") {
this.active_mic = true;
+ this._source_sink_mic_activated = true;
+ }
}
private void context_state_callback (Context c)