diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2019-07-17 05:02:25 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-07-17 05:02:25 -0700 |
commit | 0db11eb649df3937e874db5a31e63c66efcd7369 (patch) | |
tree | 97882679d3bf08214ff78e18299e3dc0f76c0a8b /hal | |
parent | 4451a4dd415bf5886b7f5459d260b0cc4d7ce868 (diff) | |
parent | 902f7d10c69d635e7bef7aec3cd3e59a5fb0877a (diff) | |
download | hardware_qcom_audio-0db11eb649df3937e874db5a31e63c66efcd7369.tar.gz hardware_qcom_audio-0db11eb649df3937e874db5a31e63c66efcd7369.tar.bz2 hardware_qcom_audio-0db11eb649df3937e874db5a31e63c66efcd7369.zip |
Merge "audio: introduce dedicated adev->cal_lock for gef interfaces"
Diffstat (limited to 'hal')
-rw-r--r-- | hal/audio_extn/audio_extn.h | 4 | ||||
-rw-r--r-- | hal/audio_extn/gef.c | 54 | ||||
-rw-r--r-- | hal/audio_hw.c | 27 | ||||
-rw-r--r-- | hal/audio_hw.h | 1 |
4 files changed, 38 insertions, 48 deletions
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index 2b60ffaf..d5d175b7 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -895,7 +895,7 @@ int audio_extn_keep_alive_set_parameters(struct audio_device *adev, #ifndef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED #define audio_extn_gef_init(adev) (0) -#define audio_extn_gef_deinit() (0) +#define audio_extn_gef_deinit(adev) (0) #define audio_extn_gef_notify_device_config(devices, cmask, sample_rate, acdb_id) (0) #ifndef INSTANCE_ID_ENABLED @@ -925,7 +925,7 @@ int audio_extn_keep_alive_set_parameters(struct audio_device *adev, #else void audio_extn_gef_init(struct audio_device *adev); -void audio_extn_gef_deinit(); +void audio_extn_gef_deinit(struct audio_device *adev); void audio_extn_gef_notify_device_config(audio_devices_t audio_device, audio_channel_mask_t channel_mask, int sample_rate, int acdb_id); diff --git a/hal/audio_extn/gef.c b/hal/audio_extn/gef.c index 7f82a8ad..cfed6b36 100644 --- a/hal/audio_extn/gef.c +++ b/hal/audio_extn/gef.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -113,6 +113,7 @@ void audio_extn_gef_init(struct audio_device *adev) ALOGV("%s: Enter with error", __func__); + pthread_mutex_init(&adev->cal_lock, (const pthread_mutexattr_t *) NULL); memset(&gef_hal_handle, 0, sizeof(gef_data)); //: check error for dlopen @@ -186,8 +187,8 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -196,7 +197,7 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id, ret = platform_send_audio_cal(adev->platform, &cal, data, length, persist); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -218,8 +219,8 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -228,7 +229,7 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id, ret = platform_get_audio_cal(adev->platform, &cal, data, length, persist); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -250,8 +251,8 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -260,7 +261,7 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id, ret = platform_store_audio_cal(adev->platform, &cal, data, length); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -281,8 +282,8 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -291,7 +292,7 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id, ret = platform_retrieve_audio_cal(adev->platform, &cal, data, length); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -313,8 +314,8 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -323,7 +324,7 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id, ret = platform_send_audio_cal(adev->platform, &cal, data, length, persist); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -345,8 +346,8 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -355,7 +356,7 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id, ret = platform_get_audio_cal(adev->platform, &cal, data, length, persist); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -376,8 +377,8 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -386,7 +387,7 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id, ret = platform_store_audio_cal(adev->platform, &cal, data, length); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -407,8 +408,8 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id, ALOGV("%s: Enter", __func__); memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t)); - //lock adev - pthread_mutex_lock(&adev->lock); + //lock adev->cal_lock + pthread_mutex_lock(&adev->cal_lock); //pack cal platform_make_cal_cfg(&cal, acdb_dev_id, @@ -417,7 +418,7 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id, ret = platform_retrieve_audio_cal(adev->platform, &cal, data, length); - pthread_mutex_unlock(&adev->lock); + pthread_mutex_unlock(&adev->cal_lock); ALOGV("%s: Exit with error %d", __func__, ret); @@ -442,7 +443,7 @@ void audio_extn_gef_notify_device_config(audio_devices_t audio_device, return; } -void audio_extn_gef_deinit() +void audio_extn_gef_deinit(struct audio_device *adev) { ALOGV("%s: Enter", __func__); @@ -452,6 +453,7 @@ void audio_extn_gef_deinit() dlclose(gef_hal_handle.handle); } + pthread_mutex_destroy(&adev->cal_lock); memset(&gef_hal_handle, 0, sizeof(gef_data)); ALOGV("%s: Exit", __func__); diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 90dc8c02..de149a46 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -2103,10 +2103,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) struct stream_out stream_out; audio_usecase_t hfp_ucid; int status = 0; - audio_devices_t audio_device; - audio_channel_mask_t channel_mask; - int sample_rate; - int acdb_id; ALOGD("%s for use case (%s)", __func__, use_case_table[uc_id]); @@ -2357,11 +2353,12 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } - /* Cache stream information to be notified to gef clients */ - audio_device = usecase->stream.out->devices; - channel_mask = usecase->stream.out->channel_mask; - sample_rate = usecase->stream.out->app_type_cfg.sample_rate; - acdb_id = platform_get_snd_device_acdb_id(usecase->out_snd_device); + /* Notify device change info to effect clients registered */ + audio_extn_gef_notify_device_config( + usecase->stream.out->devices, + usecase->stream.out->channel_mask, + usecase->stream.out->app_type_cfg.sample_rate, + platform_get_snd_device_acdb_id(usecase->out_snd_device)); } enable_audio_route(adev, usecase); @@ -2419,16 +2416,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id) } } - /* Notify device change info to effect clients registered - * NOTE: device lock has to be unlock temporarily here. - * To the worst case, we notify stale info to clients. - */ - if (usecase->type == PCM_PLAYBACK) { - pthread_mutex_unlock(&adev->lock); - audio_extn_gef_notify_device_config(audio_device, channel_mask, sample_rate, acdb_id); - pthread_mutex_lock(&adev->lock); - } - ALOGD("%s: done",__func__); return status; @@ -7728,7 +7715,7 @@ static int adev_close(hw_device_t *device) if (audio_extn_qaf_is_enabled()) audio_extn_qaf_deinit(); audio_route_free(adev->audio_route); - audio_extn_gef_deinit(); + audio_extn_gef_deinit(adev); free(adev->snd_dev_ref_cnt); platform_deinit(adev->platform); if (adev->adm_deinit) diff --git a/hal/audio_hw.h b/hal/audio_hw.h index ad75d06c..f791b6ac 100644 --- a/hal/audio_hw.h +++ b/hal/audio_hw.h @@ -466,6 +466,7 @@ typedef void (*adm_on_routing_change_t)(void *, audio_io_handle_t); struct audio_device { struct audio_hw_device device; pthread_mutex_t lock; /* see note below on mutex acquisition order */ + pthread_mutex_t cal_lock; struct mixer *mixer; audio_mode_t mode; audio_devices_t out_device; |