audio: add locks, only tear down PCMs when needed for WB AMR

Change-Id: I03ba325b613aef21dba8d16187aaccca08d2a328
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index e70f767..e954fbe 100755
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -623,13 +623,18 @@
 void audio_set_wb_amr_callback(void *data, int enable)
 {
     struct tuna_audio_device *adev = (struct tuna_audio_device *)data;
-    adev->wb_amr = enable;
 
-    /* reopen the modem PCMs at the new rate */
-    if (adev->in_call) {
-        end_call(adev);
-        start_call(adev);
+    pthread_mutex_lock(&adev->lock);
+    if (adev->wb_amr != enable) {
+        adev->wb_amr = enable;
+
+        /* reopen the modem PCMs at the new rate */
+        if (adev->in_call) {
+            end_call(adev);
+            start_call(adev);
+        }
     }
+    pthread_mutex_unlock(&adev->lock);
 }
 
 static void set_incall_device(struct tuna_audio_device *adev)