diff --git a/hal/acdb.c b/hal/acdb.c index 182e5139..ad67d61a 100644 --- a/hal/acdb.c +++ b/hal/acdb.c @@ -34,7 +34,7 @@ int acdb_init(int snd_card_num) int result = -1; char *cvd_version = NULL; - char *snd_card_name = NULL; + const char *snd_card_name = NULL; struct mixer *mixer = NULL; struct acdb_platform_data *my_data = NULL; @@ -115,13 +115,14 @@ int acdb_init(int snd_card_num) } /* Get Sound card name */ - snd_card_name = strdup(mixer_get_name(mixer)); + snd_card_name = mixer_get_name(mixer); if (!snd_card_name) { ALOGE("failed to allocate memory for snd_card_name"); result = -1; goto cleanup; } + snd_card_name = platform_get_snd_card_name_for_acdb_loader(snd_card_name); int key = 0; struct listnode *node = NULL; struct meta_key_list *key_info = NULL; @@ -160,9 +161,6 @@ cleanup: if (cvd_version) free(cvd_version); - if (snd_card_name) - free(snd_card_name); - return result; } diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index ef23b152..c6b0bc82 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -1851,7 +1851,7 @@ static void audio_hwdep_send_cal(struct platform_data *plat_data) plat_data->hw_dep_fd = fd; } -const char * get_snd_card_name_for_acdb_loader(const char *snd_card_name) { +const char * platform_get_snd_card_name_for_acdb_loader(const char *snd_card_name) { if(snd_card_name == NULL) return NULL; @@ -1905,7 +1905,7 @@ int platform_acdb_init(void *platform) { struct platform_data *my_data = (struct platform_data *)platform; char *cvd_version = NULL; - const char *snd_card_name, *acdb_snd_card_name; + const char *snd_card_name; int result = -1; struct listnode *node; struct meta_key_list *key_info; @@ -1920,21 +1920,21 @@ int platform_acdb_init(void *platform) } snd_card_name = mixer_get_name(my_data->adev->mixer); - acdb_snd_card_name = get_snd_card_name_for_acdb_loader(snd_card_name); + snd_card_name = platform_get_snd_card_name_for_acdb_loader(snd_card_name); if (my_data->acdb_init_v3) { - result = my_data->acdb_init_v3(acdb_snd_card_name, cvd_version, + result = my_data->acdb_init_v3(snd_card_name, cvd_version, &my_data->acdb_meta_key_list); } else if (my_data->acdb_init) { node = list_head(&my_data->acdb_meta_key_list); key_info = node_to_item(node, struct meta_key_list, list); key = key_info->cal_info.nKey; - result = my_data->acdb_init(acdb_snd_card_name, cvd_version, key); + result = my_data->acdb_init(snd_card_name, cvd_version, key); } /* Save these variables in platform_data. These will be used while reloading ACDB files during run time. */ strlcpy(my_data->cvd_version, cvd_version, MAX_CVD_VERSION_STRING_SIZE); - strlcpy(my_data->snd_card_name, acdb_snd_card_name, + strlcpy(my_data->snd_card_name, snd_card_name, MAX_SND_CARD_STRING_SIZE); if (cvd_version) diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index b41784e0..7bea5f1a 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -1730,7 +1730,7 @@ static void audio_hwdep_send_cal(struct platform_data *plat_data) plat_data->hw_dep_fd = fd; } -const char * get_snd_card_name_for_acdb_loader(const char *snd_card_name) { +const char * platform_get_snd_card_name_for_acdb_loader(const char *snd_card_name) { if(snd_card_name == NULL) return NULL; @@ -1767,7 +1767,7 @@ static int platform_acdb_init(void *platform) } snd_card_name = mixer_get_name(my_data->adev->mixer); - snd_card_name = get_snd_card_name_for_acdb_loader(snd_card_name); + snd_card_name = platform_get_snd_card_name_for_acdb_loader(snd_card_name); if (my_data->acdb_init_v3) { result = my_data->acdb_init_v3(snd_card_name, cvd_version, diff --git a/hal/platform_api.h b/hal/platform_api.h index e72c6e93..0fec4525 100644 --- a/hal/platform_api.h +++ b/hal/platform_api.h @@ -260,4 +260,5 @@ int platform_get_max_codec_backend(); int platform_get_mmap_data_fd(void *platform, int dev, int dir, int *fd, uint32_t *size); int platform_get_ec_ref_loopback_snd_device(int channel_count); +const char * platform_get_snd_card_name_for_acdb_loader(const char *snd_card_name); #endif // AUDIO_PLATFORM_API_H