qahw: test: Implement new api of set param for SourceTrack
Implement new api qahw_set_param_data to set SourceTracking
parameters in given payload.
Change-Id: I5499d91eab08342c6d567a28997f8a58e8f0a71e
diff --git a/qahw_api/src/qahw.c b/qahw_api/src/qahw.c
index 4025c56..1cb89ee 100644
--- a/qahw_api/src/qahw.c
+++ b/qahw_api/src/qahw.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2017, 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
@@ -50,6 +50,12 @@
typedef uint64_t (*qahwi_in_read_v2_t)(audio_stream_in_t *in, void* buffer,
size_t bytes, uint64_t *timestamp);
+typedef int (*qahwi_get_param_data_t) (const audio_hw_device_t *,
+ qahw_param_id, qahw_param_payload *);
+
+typedef int (*qahwi_set_param_data_t) (audio_hw_device_t *,
+ qahw_param_id, qahw_param_payload *);
+
typedef struct {
audio_hw_device_t *audio_device;
char module_name[MAX_MODULE_NAME_LENGTH];
@@ -59,6 +65,8 @@
pthread_mutex_t lock;
uint32_t ref_count;
const hw_module_t* module;
+ qahwi_get_param_data_t qahwi_get_param_data;
+ qahwi_set_param_data_t qahwi_set_param_data;
} qahw_module_t;
typedef struct {
@@ -91,9 +99,6 @@
static int qahw_list_count;
static pthread_mutex_t qahw_module_init_lock = PTHREAD_MUTEX_INITIALIZER;
-typedef int (*qahwi_get_param_data_t) (const struct audio_device *,
- qahw_param_id, qahw_param_payload *);
-qahwi_get_param_data_t qahwi_get_param_data;
/** Start of internal functions */
/******************************************************************************/
@@ -1233,8 +1238,43 @@
pthread_mutex_lock(&qahw_module->lock);
- if (qahwi_get_param_data){
- ret = qahwi_get_param_data (qahw_module->audio_device, param_id, payload);
+ if (qahw_module->qahwi_get_param_data){
+ ret = qahw_module->qahwi_get_param_data (qahw_module->audio_device,
+ param_id, payload);
+ } else {
+ ret = -ENOSYS;
+ ALOGE("%s not supported\n",__func__);
+ }
+ pthread_mutex_unlock(&qahw_module->lock);
+
+exit:
+ return ret;
+}
+
+/* Api to implement set parameters based on keyword param_id
+ * and data present in payload.
+ */
+int qahw_set_param_data(const qahw_module_handle_t *hw_module,
+ qahw_param_id param_id,
+ qahw_param_payload *payload)
+{
+ int ret = 0;
+ qahw_module_t *qahw_module = (qahw_module_t *)hw_module;
+ qahw_module_t *qahw_module_temp;
+
+ pthread_mutex_lock(&qahw_module_init_lock);
+ qahw_module_temp = get_qahw_module_by_ptr(qahw_module);
+ pthread_mutex_unlock(&qahw_module_init_lock);
+ if (qahw_module_temp == NULL) {
+ ALOGE("%s:: invalid hw module %p", __func__, qahw_module);
+ goto exit;
+ }
+
+ pthread_mutex_lock(&qahw_module->lock);
+
+ if (qahw_module->qahwi_set_param_data){
+ ret = qahw_module->qahwi_set_param_data (qahw_module->audio_device,
+ param_id, payload);
} else {
ret = -ENOSYS;
ALOGE("%s not supported\n",__func__);
@@ -1544,11 +1584,16 @@
qahw_module->module = module;
ALOGD("%s::Loaded HAL %s module %p", __func__, ahal_name, qahw_module);
- qahwi_get_param_data = (qahwi_get_param_data_t) dlsym (module->dso,
+ qahw_module->qahwi_get_param_data = (qahwi_get_param_data_t) dlsym (module->dso,
"qahwi_get_param_data");
- if (!qahwi_get_param_data)
+ if (!qahw_module->qahwi_get_param_data)
ALOGD("%s::qahwi_get_param_data api is not defined\n",__func__);
+ qahw_module->qahwi_set_param_data = (qahwi_set_param_data_t) dlsym (module->dso,
+ "qahwi_set_param_data");
+ if (!qahw_module->qahwi_set_param_data)
+ ALOGD("%s::qahwi_set_param_data api is not defined\n",__func__);
+
if (!qahw_list_count)
list_init(&qahw_module_list);
qahw_list_count++;