Merge changes I5d71550f,Iace30af1

* changes:
  Fix platform_get_snd_device_name_extn functions.
  Fix compiler warnings.
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e68535f..2d50698 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2076,9 +2076,9 @@
     pthread_mutex_unlock(&out->lock);
 
     if (ret != 0) {
-        out_on_error(&out->stream.common);
         if (out->pcm)
             ALOGE("%s: error %zu - %s", __func__, ret, pcm_get_error(out->pcm));
+        out_on_error(&out->stream.common);
         if (out->usecase != USECASE_AUDIO_PLAYBACK_OFFLOAD)
             usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
                    out_get_sample_rate(&out->stream.common));
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index a97d5be..8ff2bfa 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2757,6 +2757,14 @@
     struct platform_data *my_data = (struct platform_data *)adev->platform;
 
     if (my_data->speaker_lr_swap != swap_channels) {
+
+        // do not swap channels in audio modes with concurrent capture and playback
+        // as this may break the echo reference
+        if ((adev->mode == AUDIO_MODE_IN_COMMUNICATION) || (adev->mode == AUDIO_MODE_IN_CALL)) {
+            ALOGV("%s: will not swap due to audio mode %d", __func__, adev->mode);
+            return 0;
+        }
+
         my_data->speaker_lr_swap = swap_channels;
 
         list_for_each(node, &adev->usecase_list) {