aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-07 10:13:52 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2016-03-07 10:13:52 +0000
commita03ba9b8fe38bad63a5b14096dfadc7341e1eac6 (patch)
tree4f9756dc0694d4fd2fe25087317a80a9f468205d /src
parent5e59aeb7d963648d0975799ad69da865dc552bf7 (diff)
parent1cc5e45c976b428730e928fa10c57288129ba0e1 (diff)
downloadayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.tar.gz
ayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.tar.bz2
ayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.zip
Add changes to show up the microphone controls when an external microphone is detected.
Approved by: PS Jenkins bot, Charles Kerr
Diffstat (limited to 'src')
-rw-r--r--src/volume-control-pulse.vala33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index c8a6071..653a1bd 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; }
@@ -139,6 +141,22 @@ public class VolumeControlPulse : VolumeControl
return ret_output;
}
+ private bool is_external_mic (SourceInfo? sink) {
+ if (sink.name.contains ("indicator_sound_test_mic")) {
+ return true;
+ }
+ 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)
{
@@ -180,7 +198,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 +248,14 @@ public class VolumeControlPulse : VolumeControl
if (i == null)
return;
+ if (is_external_mic (i)) {
+ 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 +461,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)