aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-03 16:13:56 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-03 16:13:56 +0100
commit2a6cae12898e132e9c50973999d85b0e80a33f4a (patch)
tree3d00979eb5e2a8d1f2e74c04ad93e378a29cd44f
parent19d447425a8eaee64291ce1667d82506de065756 (diff)
downloadayatana-indicator-sound-2a6cae12898e132e9c50973999d85b0e80a33f4a.tar.gz
ayatana-indicator-sound-2a6cae12898e132e9c50973999d85b0e80a33f4a.tar.bz2
ayatana-indicator-sound-2a6cae12898e132e9c50973999d85b0e80a33f4a.zip
Added is_external_mic function to check for an external microphone
-rw-r--r--src/volume-control-pulse.vala20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 92f12a3..9d572a3 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -141,6 +141,19 @@ public class VolumeControlPulse : VolumeControl
return ret_output;
}
+ private bool is_external_mic (SourceInfo? sink) {
+ if (sink.active_port != null &&
+ ( (sink.active_port.name.contains ("headphone") ||
+ sink.active_port.name.contains ("headset") ||
+ sink.active_port.name.contains ("mic") ) &&
+ (!sink.active_port.name.contains ("internal") &&
+ !sink.active_port.name.contains ("builtin")) )) {
+ return true;
+ }
+ return false;
+ }
+
+
/* PulseAudio logic*/
private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index)
{
@@ -232,12 +245,7 @@ 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")) )) {
+ if (is_external_mic (i)) {
this.active_mic = true;
_external_mic_detected = true;
} else {