hal: Start A2DP playback after fetching parameters for audio route

Start A2DP playback after all parameters have been fetched
successfully for enabling audio route.

Bug: 78773915
Test: music playback over A2DP
Change-Id: Ida1260fa592c03cb64092b672758bf529574392d
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index f88dcdd..7f8c75a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -678,12 +678,6 @@
 
     audio_extn_dsm_feedback_enable(adev, snd_device, true);
 
-    if (is_a2dp_device(snd_device) &&
-        (audio_extn_a2dp_start_playback() < 0)) {
-           ALOGE("%s: failed to configure A2DP control path", __func__);
-           goto on_error;
-    }
-
     if ((snd_device == SND_DEVICE_OUT_SPEAKER ||
         snd_device == SND_DEVICE_OUT_SPEAKER_SAFE ||
         snd_device == SND_DEVICE_OUT_SPEAKER_REVERSE ||
@@ -711,6 +705,13 @@
         }
 
         ALOGD("%s: snd_device(%d: %s)", __func__, snd_device, device_name);
+
+        if (is_a2dp_device(snd_device) &&
+            (audio_extn_a2dp_start_playback() < 0)) {
+               ALOGE("%s: failed to configure A2DP control path", __func__);
+               goto on_error;
+        }
+
         audio_route_apply_and_update_path(adev->audio_route, device_name);
     }
 on_success:
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 6d0a6cf..fa62ea9 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1893,6 +1893,7 @@
         hw_info_append_hw_type(my_data->hw_info, snd_device, device_name);
     } else {
         strlcpy(device_name, "none", DEVICE_NAME_MAX_SIZE);
+        return -EINVAL;
     }
 
     return 0;