a2dp : pcm prepare fail for input during a2dp suspend and reconfig

Start input is failing due to race condition in a2dp suspend
and a2dp connection/disconnection. If a2dp suspend params are
and then a2dp disconnection comes, reseting the suspended
flag can cause a2dp_is_ready function return invalid value
during start input and hence pcm prepare fails.
Avoid setting a2dp suspend state to false if sco is still on.

Change-Id: I83950ddd0d4d3bbe6f30846cba48f6eb88c14690
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index b8a696f..06d2638 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -1146,6 +1146,8 @@
                 ALOGE("Failed to open source stream for a2dp: status %d", ret);
             }
             a2dp.bt_state_source = A2DP_STATE_CONNECTED;
+            if (!a2dp.adev->bt_sco_on)
+                a2dp.a2dp_source_suspended = false;
         } else {
             ALOGD("Called a2dp open with improper state %d", a2dp.bt_state_source);
         }
@@ -1258,7 +1260,8 @@
     }
     a2dp.a2dp_source_started = false;
     a2dp.a2dp_source_total_active_session_requests = 0;
-    a2dp.a2dp_source_suspended = false;
+    if (!a2dp.adev->bt_sco_on)
+        a2dp.a2dp_source_suspended = false;
     a2dp.bt_encoder_format = CODEC_TYPE_INVALID;
     a2dp.enc_sampling_rate = 48000;
     a2dp.enc_channels = 2;
@@ -3470,6 +3473,13 @@
         goto param_handled;
     }
 
+    ret = str_parms_get_str(parms, "BT_SCO", value, sizeof(value));
+    if (ret >= 0) {
+        if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0) {
+            a2dp.a2dp_source_suspended = true;
+        }
+    }
+
 param_handled:
     ALOGV("end of a2dp setparam");
     return status;