Merge "Revert "Fix build"" into nyc-dev
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 297ddd4..72ef56c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -689,9 +689,36 @@
         return 0;
     }
 
-    ALOGV("%s: out_snd_device(%d: %s) in_snd_device(%d: %s)", __func__,
-          out_snd_device, platform_get_snd_device_name(out_snd_device),
-          in_snd_device,  platform_get_snd_device_name(in_snd_device));
+    if (out_snd_device != SND_DEVICE_NONE &&
+            out_snd_device != adev->last_logged_snd_device[uc_id][0]) {
+        ALOGD("%s: changing use case %s output device from(%d: %s, acdb %d) to (%d: %s, acdb %d)",
+              __func__,
+              use_case_table[uc_id],
+              adev->last_logged_snd_device[uc_id][0],
+              platform_get_snd_device_name(adev->last_logged_snd_device[uc_id][0]),
+              adev->last_logged_snd_device[uc_id][0] != SND_DEVICE_NONE ?
+                      platform_get_snd_device_acdb_id(adev->last_logged_snd_device[uc_id][0]) :
+                      -1,
+              out_snd_device,
+              platform_get_snd_device_name(out_snd_device),
+              platform_get_snd_device_acdb_id(out_snd_device));
+        adev->last_logged_snd_device[uc_id][0] = out_snd_device;
+    }
+    if (in_snd_device != SND_DEVICE_NONE &&
+            in_snd_device != adev->last_logged_snd_device[uc_id][1]) {
+        ALOGD("%s: changing use case %s input device from(%d: %s, acdb %d) to (%d: %s, acdb %d)",
+              __func__,
+              use_case_table[uc_id],
+              adev->last_logged_snd_device[uc_id][1],
+              platform_get_snd_device_name(adev->last_logged_snd_device[uc_id][1]),
+              adev->last_logged_snd_device[uc_id][1] != SND_DEVICE_NONE ?
+                      platform_get_snd_device_acdb_id(adev->last_logged_snd_device[uc_id][1]) :
+                      -1,
+              in_snd_device,
+              platform_get_snd_device_name(in_snd_device),
+              platform_get_snd_device_acdb_id(in_snd_device));
+        adev->last_logged_snd_device[uc_id][1] = in_snd_device;
+    }
 
     /*
      * Limitation: While in call, to do a device switch we need to disable
@@ -880,7 +907,7 @@
 
 error_config:
     adev->active_input = NULL;
-    ALOGV("%s: exit: status(%d)", __func__, ret);
+    ALOGW("%s: exit: status(%d)", __func__, ret);
 
     return ret;
 }
@@ -2400,7 +2427,7 @@
 error_open:
     free(out);
     *stream_out = NULL;
-    ALOGV("%s: exit: ret %d", __func__, ret);
+    ALOGW("%s: exit: ret %d", __func__, ret);
     return ret;
 }
 
@@ -2567,7 +2594,7 @@
 
     pthread_mutex_lock(&adev->lock);
     if (adev->mode != mode) {
-        ALOGV("%s: mode %d\n", __func__, mode);
+        ALOGD("%s: mode %d", __func__, (int)mode);
         adev->mode = mode;
         if ((mode == AUDIO_MODE_NORMAL || mode == AUDIO_MODE_IN_COMMUNICATION) &&
                 voice_is_in_call(adev)) {
@@ -2587,7 +2614,7 @@
     int ret;
     struct audio_device *adev = (struct audio_device *)dev;
 
-    ALOGV("%s: state %d\n", __func__, state);
+    ALOGD("%s: state %d", __func__, (int)state);
     pthread_mutex_lock(&adev->lock);
     ret = voice_set_mic_mute(adev, state);
     adev->mic_muted = state;
@@ -2921,7 +2948,7 @@
 {
     int i, ret;
 
-    ALOGV("%s: enter", __func__);
+    ALOGD("%s: enter", __func__);
     if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL;
     pthread_mutex_lock(&adev_init_lock);
     if (audio_device_ref_count != 0) {
@@ -3075,7 +3102,7 @@
 
     audio_extn_perf_lock_init();
 
-    ALOGV("%s: exit", __func__);
+    ALOGD("%s: exit", __func__);
     return 0;
 }
 
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 7955894..9a956f9 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -279,6 +279,10 @@
     adm_deregister_stream_t adm_deregister_stream;
     adm_request_focus_t adm_request_focus;
     adm_abandon_focus_t adm_abandon_focus;
+
+    /* logging */
+    snd_device_t last_logged_snd_device[AUDIO_USECASE_MAX][2]; /* [out, in] */
+
 };
 
 int select_devices(struct audio_device *adev,
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 7dc755c..7d871e7 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -491,7 +491,7 @@
     int mccmnc;
     property_get("gsm.sim.operator.numeric",value,"0");
     mccmnc = atoi(value);
-    ALOGV("%s: tmus mccmnc %d", __func__, mccmnc);
+    ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
     switch(mccmnc) {
     /* TMUS MCC(310), MNC(490, 260, 026) */
     case 310490:
@@ -834,7 +834,7 @@
         goto done;
     }
 
-    ALOGV("%s: num_modems %d\n", __func__, modems);
+    ALOGD("%s: num_modems %d\n", __func__, modems);
     if (modems > 0)
         my_data->csd = open_csd_client(false /*is_i2s_ext_modem*/);
 
@@ -1043,7 +1043,7 @@
             goto init_failed;
         }
         adev->snd_card = snd_card_num;
-        ALOGV("%s: Opened sound card:%d", __func__, snd_card_num);
+        ALOGD("%s: Opened sound card:%d", __func__, snd_card_num);
         break;
     }
 
@@ -1410,7 +1410,7 @@
 
     list_add_tail(operator_specific_device_table[snd_device], &device->list);
 
-    ALOGV("%s : deivce[%s] -> operator[%s] mixer_path[%s] acdb_id [%d]", __func__,
+    ALOGD("%s: device[%s] -> operator[%s] mixer_path[%s] acdb_id[%d]", __func__,
             platform_get_snd_device_name(snd_device), operator, mixer_path, acdb_id);
 
 }