hal: Avoid multiple mixer open calls during init

audio_extn_utils_get_snd_card_num opens the mixer for
primary sound card. clients of this API are opening the
mixer again for the same card. Multiple mixer open calls
during HAL initialization are adding to boot up latency.

Return mixer handle as well along with the sound card
number from audio_extn_utils_open_snd_mixer. Added
close API as well to be consistent with the open API.
Retained old APIs for backward compatability with
ST HAL.

CRs-Fixed: 2205214
Change-Id: I323ee7a3c3fe446cd268b46a6e2c498467273ddb
diff --git a/hal/acdb.c b/hal/acdb.c
index bb8ceff..8f3ea83 100644
--- a/hal/acdb.c
+++ b/hal/acdb.c
@@ -61,11 +61,7 @@
 {
 
     int result = -1;
-    char *cvd_version = NULL;
-
-    const char *snd_card_name = NULL;
     struct mixer *mixer = NULL;
-    struct acdb_platform_data *my_data = NULL;
 
     if(snd_card_num < 0) {
         ALOGE("invalid sound card number");
@@ -76,7 +72,25 @@
     if (!mixer) {
         ALOGE("%s: Unable to open the mixer card: %d", __func__,
                snd_card_num);
-        goto cleanup;
+        return result;
+    }
+    result = acdb_init_v2(mixer);
+    mixer_close(mixer);
+    return result;
+}
+
+int acdb_init_v2(struct mixer *mixer)
+{
+
+    int result = -1;
+    char *cvd_version = NULL;
+
+    const char *snd_card_name = NULL;
+    struct acdb_platform_data *my_data = NULL;
+
+    if (!mixer) {
+       ALOGE("Invalid mixer handle");
+       return result;
     }
 
     my_data = calloc(1, sizeof(struct acdb_platform_data));
@@ -200,9 +214,6 @@
         free(my_data);
     }
 
-    if (mixer)
-        mixer_close(mixer);
-
     if (cvd_version)
         free(cvd_version);