audio: Add support for two mic control
authorAndreas Schneider <asn@cryptomilk.org>
Mon, 6 Feb 2017 08:00:48 +0000 (09:00 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Sat, 11 Feb 2017 13:23:16 +0000 (14:23 +0100)
Change-Id: I0176b41b071577e9e55f5177ec1219d4e9aa91a2

audio/audio_hw.c
audio/audio_hw.h
audio/voice.c
audio/voice.h

index d43fecbd8cd3e0c2e3aeafa81c92c3fd0e8b1f9b..abec559a2e3dbfb790d1e7d3199221852149638c 100644 (file)
@@ -323,6 +323,8 @@ static const char * const device_table[SND_DEVICE_MAX] = {
     [SND_DEVICE_IN_EARPIECE_MIC_AEC] = "earpiece-mic",
     [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
     [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
+    [SND_DEVICE_IN_VOICE_MIC] = "voice-mic",
+    [SND_DEVICE_IN_VOICE_EARPIECE_MIC] = "voice-earpiece-mic",
     [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
     [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
     [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
@@ -609,15 +611,20 @@ static snd_device_t get_input_snd_device(struct audio_device *adev, audio_device
             goto exit;
         }
 
-        if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
-                out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
-            snd_device = SND_DEVICE_IN_EARPIECE_MIC;
-        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
+        snd_device = SND_DEVICE_IN_VOICE_MIC;
+        if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
             snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
         } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
-            snd_device = SND_DEVICE_IN_BT_SCO_MIC ;
-        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
-            snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
+            snd_device = SND_DEVICE_IN_BT_SCO_MIC;
+        }
+
+        if (voice_session_uses_twomic(adev->voice.session)) {
+            if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
+                out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
+                snd_device = SND_DEVICE_IN_VOICE_EARPIECE_MIC;
+            } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
+                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
+            }
         }
     } else if (source == AUDIO_SOURCE_CAMCORDER) {
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
index 8a507ed3006434b5e693da9532cbfd2ff0542638..74be201d19d9aa5eff81d15e340a4494c63a3dad 100644 (file)
@@ -87,6 +87,8 @@ enum {
     SND_DEVICE_IN_EARPIECE_MIC_AEC,
     SND_DEVICE_IN_SPEAKER_MIC_AEC,
     SND_DEVICE_IN_HEADSET_MIC_AEC,
+    SND_DEVICE_IN_VOICE_MIC,
+    SND_DEVICE_IN_VOICE_EARPIECE_MIC,
     SND_DEVICE_IN_VOICE_SPEAKER_MIC,
     SND_DEVICE_IN_VOICE_HEADSET_MIC,
     SND_DEVICE_IN_HDMI_MIC,
index f10d8ed7f7b274821577ac2fe65ac70d0b6ddd4c..e59565aab2ed60b44da3c2cc8916326d6e972901 100644 (file)
@@ -244,6 +244,15 @@ void set_voice_session_volume(struct voice_session *session, float volume)
     ril_set_call_volume(&session->ril, sound_type, volume);
 }
 
+bool voice_session_uses_twomic(struct voice_session *session)
+{
+    if (session->two_mic_disabled) {
+        return false;
+    }
+
+    return session->two_mic_control;
+}
+
 static void voice_session_wb_amr_callback(void *data, int enable)
 {
     struct audio_device *adev = (struct audio_device *)data;
index 0e32f0aed256e227fdc433fda2e19da037db606f..c63cd26da24567889100378e4b102b042c4f69b4 100644 (file)
@@ -40,6 +40,8 @@ void stop_voice_session(struct voice_session *session);
 void set_voice_session_volume(struct voice_session *session, float volume);
 void set_voice_session_audio_path(struct voice_session *session);
 
+bool voice_session_uses_twomic(struct voice_session *session);
+
 struct voice_session *voice_session_init(struct audio_device *adev);
 void voice_session_deinit(struct voice_session *s);