qahw_api: Propagate missing changes from 2.2.c4 to 4.0
Add support for audio effects through binder server
calls if QAS is enabled. Else the required APIs are
called directly.
Change-Id: I1f45ae89b839e69c49cbca407ddb05b7a02d3dc6
diff --git a/qahw/inc/qahw.h b/qahw/inc/qahw.h
index b7088ed..e91fd00 100644
--- a/qahw/inc/qahw.h
+++ b/qahw/inc/qahw.h
@@ -27,8 +27,10 @@
#include <cutils/bitops.h>
#include <system/audio.h>
#include "qahw_defs.h"
+#include "qahw_effect_api.h"
__BEGIN_DECLS
+
/*
* Helper macros for module implementors.
*
@@ -473,6 +475,41 @@
/* Set audio port configuration */
int qahw_set_audio_port_config_l(qahw_module_handle_t *hw_module,
const struct audio_port_config *config);
+
+/* Audio effects API */
+qahw_effect_lib_handle_t qahw_effect_load_library_l(const char *lib_path);
+
+int32_t qahw_effect_unload_library_l(qahw_effect_lib_handle_t handle);
+
+int32_t qahw_effect_create_l(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ int32_t io_handle,
+ qahw_effect_handle_t *effect_handle);
+
+int32_t qahw_effect_release_l(qahw_effect_lib_handle_t handle,
+ qahw_effect_handle_t effect_handle);
+
+int32_t qahw_effect_get_descriptor_l(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ qahw_effect_descriptor_t *effect_desc);
+
+int32_t qahw_effect_get_version_l();
+
+int32_t qahw_effect_process_l(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer);
+
+int32_t qahw_effect_command_l(qahw_effect_handle_t self,
+ uint32_t cmd_code,
+ uint32_t cmd_size,
+ void *cmd_data,
+ uint32_t *reply_size,
+ void *reply_data);
+
+int32_t qahw_effect_process_reverse_l(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer);
+
#ifdef __cplusplus
}
#endif
diff --git a/qahw/src/qahw_effect.c b/qahw/src/qahw_effect.c
index 2eff79f..9bee2a1 100644
--- a/qahw/src/qahw_effect.c
+++ b/qahw/src/qahw_effect.c
@@ -39,7 +39,6 @@
#include <stdlib.h>
#include "qahw.h"
-#include "qahw_effect_api.h"
// The current effect API version.
#define QAHW_EFFECT_API_VERSION_CURRENT QAHW_EFFECT_API_VERSION_0_0
@@ -97,7 +96,7 @@
}
-qahw_effect_lib_handle_t qahw_effect_load_library(const char *lib_path) {
+qahw_effect_lib_handle_t qahw_effect_load_library_l(const char *lib_path) {
audio_effect_library_t *desc;
qahw_effect_lib_t *qahw_effect_lib;
void *handle;
@@ -175,7 +174,7 @@
}
-int32_t qahw_effect_unload_library(qahw_effect_lib_handle_t handle) {
+int32_t qahw_effect_unload_library_l(qahw_effect_lib_handle_t handle) {
qahw_effect_lib_t *qahw_effect_lib;
pthread_mutex_lock(&effect_libraries_lock);
@@ -214,7 +213,7 @@
}
-int32_t qahw_effect_create(qahw_effect_lib_handle_t handle,
+int32_t qahw_effect_create_l(qahw_effect_lib_handle_t handle,
const qahw_effect_uuid_t *uuid,
int32_t io_handle,
qahw_effect_handle_t *effect_handle) {
@@ -230,7 +229,7 @@
}
-int32_t qahw_effect_release(qahw_effect_lib_handle_t handle,
+int32_t qahw_effect_release_l(qahw_effect_lib_handle_t handle,
qahw_effect_handle_t effect_handle) {
int32_t rc = -EINVAL;
audio_effect_library_t *desc = (audio_effect_library_t *)handle;
@@ -243,7 +242,7 @@
}
-int32_t qahw_effect_get_descriptor(qahw_effect_lib_handle_t handle,
+int32_t qahw_effect_get_descriptor_l(qahw_effect_lib_handle_t handle,
const qahw_effect_uuid_t *uuid,
qahw_effect_descriptor_t *effect_desc) {
int32_t rc = -EINVAL;
@@ -257,12 +256,12 @@
}
-int32_t qahw_effect_get_version() {
+int32_t qahw_effect_get_version_l() {
return QAHW_EFFECT_API_VERSION_CURRENT;
}
-int32_t qahw_effect_process(qahw_effect_handle_t self,
+int32_t qahw_effect_process_l(qahw_effect_handle_t self,
qahw_audio_buffer_t *in_buffer,
qahw_audio_buffer_t *out_buffer) {
int32_t rc = -EINVAL;
@@ -281,7 +280,7 @@
}
-int32_t qahw_effect_command(qahw_effect_handle_t self,
+int32_t qahw_effect_command_l(qahw_effect_handle_t self,
uint32_t cmd_code,
uint32_t cmd_size,
void *cmd_data,
@@ -302,7 +301,7 @@
}
-int32_t qahw_effect_process_reverse(qahw_effect_handle_t self,
+int32_t qahw_effect_process_reverse_l(qahw_effect_handle_t self,
qahw_audio_buffer_t *in_buffer,
qahw_audio_buffer_t *out_buffer) {
int32_t rc = -EINVAL;
diff --git a/qahw_api/src/qahw_api.cpp b/qahw_api/src/qahw_api.cpp
index 8967bd6..8967e79 100644
--- a/qahw_api/src/qahw_api.cpp
+++ b/qahw_api/src/qahw_api.cpp
@@ -64,14 +64,23 @@
/* Flag to indicate qas status */
bool g_qas_died = false;
/* Count how many times hal is loaded */
-static unsigned int g_qas_load_count;
+static unsigned int g_qas_load_count = 0;
/* Store HAL handle */
qahw_module_handle_t *g_qas_handle = NULL;
+inline int qas_status(sp<Iqti_audio_server> server)
+{
+ if (server == 0) {
+ ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
+ return -1;
+ }
+ return 1;
+}
+
void death_notifier::binderDied(const wp<IBinder>& who)
{
- struct listnode *node;
- p_stream_handle *handle;
+ struct listnode *node = NULL;
+ p_stream_handle *handle = NULL;
if (g_audio_err_cb) {
ALOGD("%s %d", __func__, __LINE__);
@@ -151,10 +160,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_sample_rate(out_handle);
} else {
return -ENODEV;
@@ -170,10 +177,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_set_sample_rate(out_handle, rate);
} else {
return -ENODEV;
@@ -189,10 +194,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_buffer_size(out_handle);
} else {
return -ENODEV;
@@ -209,10 +212,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return (audio_channel_mask_t)(-ENODEV);
- }
+ if (qas_status(qas) == -1)
+ return (audio_channel_mask_t)(-ENODEV);
return qas->qahw_out_get_channels(out_handle);
} else {
return (audio_channel_mask_t)(-ENODEV);
@@ -228,10 +229,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return AUDIO_FORMAT_INVALID;
- }
+ if (qas_status(qas) == -1)
+ return AUDIO_FORMAT_INVALID;
return qas->qahw_out_get_format(out_handle);
} else {
return AUDIO_FORMAT_INVALID;;
@@ -247,10 +246,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_standby(out_handle);
} else {
return -ENODEV;
@@ -267,10 +264,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_set_parameters(out_handle, kv_pairs);
} else {
return -ENODEV;
@@ -287,10 +282,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return NULL;
- }
+ if (qas_status(qas) == -1)
+ return NULL;
return qas->qahw_out_get_parameters(out_handle, keys);
} else {
return NULL;
@@ -308,10 +301,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_set_param_data(out_handle, param_id, payload);
} else {
return -ENODEV;
@@ -329,10 +320,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_param_data(out_handle, param_id, payload);
} else {
return -ENODEV;
@@ -348,10 +337,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_latency(out_handle);
} else {
return -ENODEV;
@@ -367,10 +354,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_set_volume(out_handle, left, right);
} else {
return -ENODEV;
@@ -386,10 +371,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_write(out_handle, out_buf);
} else {
return -ENODEV;
@@ -406,10 +389,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_render_position(out_handle, dsp_frames);
} else {
return -ENODEV;
@@ -427,10 +408,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_set_callback(out_handle, callback, cookie);
} else {
return -ENODEV;
@@ -446,10 +425,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_pause(out_handle);
} else {
return -ENODEV;
@@ -465,10 +442,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_resume(out_handle);
} else {
return -ENODEV;
@@ -484,10 +459,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
+ if (qas_status(qas) == -1)
return -ENODEV;
- }
return qas->qahw_out_drain(out_handle, type);
} else {
return -EINVAL;
@@ -503,10 +476,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_flush(out_handle);
} else {
return -ENODEV;
@@ -523,10 +494,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_out_get_presentation_position(out_handle,
frames, timestamp);
} else {
@@ -544,10 +513,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_get_sample_rate(in_handle);
} else {
return -ENODEV;
@@ -563,10 +530,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_set_sample_rate(in_handle, rate);
} else {
return -ENODEV;
@@ -582,10 +547,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_get_buffer_size(in_handle);
} else {
return -ENODEV;
@@ -601,10 +564,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_get_channels(in_handle);
} else {
return -ENODEV;
@@ -620,10 +581,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return (audio_format_t)-ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return (audio_format_t)(-ENODEV);
return qas->qahw_in_get_format(in_handle);
} else {
return (audio_format_t)-ENODEV;
@@ -639,10 +598,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return (audio_format_t)-ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_set_format(in_handle, format);
} else {
return (audio_format_t)-ENODEV;
@@ -658,10 +615,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_standby(in_handle);
} else {
return -EINVAL;
@@ -677,10 +632,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_set_parameters(in_handle, kv_pairs);
} else {
return -ENODEV;
@@ -697,10 +650,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return NULL;
- }
+ if (qas_status(qas) == -1)
+ return NULL;
return qas->qahw_in_get_parameters(in_handle, keys);
} else {
return NULL;
@@ -716,10 +667,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_read(in_handle, in_buf);
} else {
return -ENODEV;
@@ -735,10 +684,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_get_input_frames_lost(in_handle);
} else {
return -ENODEV;
@@ -755,10 +702,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_in_get_capture_position(in_handle, frames, time);
} else {
return -ENODEV;
@@ -774,10 +719,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_init_check(hw_module);
} else {
return -ENODEV;
@@ -793,10 +736,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_voice_volume(hw_module, volume);
} else {
return -ENODEV;
@@ -812,10 +753,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_mode(hw_module, mode);;
} else {
return -ENODEV;
@@ -831,10 +770,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_mic_mute(hw_module, state);
} else {
return -ENODEV;
@@ -850,10 +787,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_get_mic_mute(hw_module, state);
} else {
return -ENODEV;
@@ -869,10 +804,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_parameters(hw_module, kv_pairs);
} else {
return -ENODEV;
@@ -889,10 +822,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return NULL;
- }
+ if (qas_status(qas) == -1)
+ return NULL;
return qas->qahw_get_parameters(hw_module, keys);;
} else {
return NULL;
@@ -910,10 +841,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_get_param_data(hw_module, param_id, payload);
} else {
return -ENODEV;
@@ -931,10 +860,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_param_data(hw_module, param_id, payload);
} else {
return -ENODEV;
@@ -955,10 +882,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_create_audio_patch(hw_module, num_sources,
sources, num_sinks, sinks,
handle);
@@ -979,10 +904,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_release_audio_patch(hw_module, handle);
} else {
return -ENODEV;
@@ -999,10 +922,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_get_audio_port(hw_module, port);
} else {
return -ENODEV;
@@ -1019,10 +940,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_set_audio_port_config(hw_module, config);
} else {
return -ENODEV;
@@ -1039,10 +958,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_get_input_buffer_size(hw_module, config);
} else {
return -ENODEV;
@@ -1064,10 +981,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_open_output_stream(hw_module, handle, devices,
flags, config, out_handle,
address);
@@ -1088,14 +1003,13 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_close_output_stream(out_handle);
} else {
- p_stream_handle *handle;
- struct listnode *node, *tempnode;
+ p_stream_handle *handle = NULL;
+ struct listnode *node = NULL;
+ struct listnode *tempnode = NULL;
pthread_mutex_lock(&list_lock);
list_for_each_safe(node, tempnode, &stream_list) {
handle = node_to_item(node, p_stream_handle, list);
@@ -1105,10 +1019,9 @@
ALOGD("%s %d: clear memory of handle %p &handle %p", __func__, __LINE__, handle, &handle);
handle->sh_mem_dealer.clear();
handle->sh_mem_handle.clear();
+ list_remove(node);
+ free(node_to_item(node, p_stream_handle, list));
}
- list_remove(node);
- free(node_to_item(node, p_stream_handle, list));
- ALOGD("%s %d: Freed node", __func__, __LINE__);
}
pthread_mutex_unlock(&list_lock);
return -ENODEV;
@@ -1131,10 +1044,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_open_input_stream(hw_module, handle, devices,
config, in_handle, flags,
address, source);
@@ -1154,14 +1065,13 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_close_input_stream(in_handle);
} else {
- p_stream_handle *handle;
- struct listnode *node, *tempnode;
+ p_stream_handle *handle = NULL;
+ struct listnode *node = NULL;
+ struct listnode *tempnode = NULL;
pthread_mutex_lock(&list_lock);
list_for_each_safe(node, tempnode, &stream_list) {
ALOGD("%s %d", __func__, __LINE__);
@@ -1169,13 +1079,12 @@
p_stream_handle *p_stream = (p_stream_handle *)in_handle;
if (handle != NULL && handle == p_stream) {
sh_mem_data *shmem_data = handle->shmem_data;
- ALOGD("%s %d: clear memory of handle %p &handle %p", __func__, __LINE__, handle, &handle);
+ ALOGV("%s %d: clear memory of handle %p", __func__, __LINE__, handle);
handle->sh_mem_dealer.clear();
handle->sh_mem_handle.clear();
+ list_remove(node);
+ free(node_to_item(node, p_stream_handle, list));
}
- list_remove(node);
- free(node_to_item(node, p_stream_handle, list));
- ALOGD("%s %d: Freed node", __func__, __LINE__);
}
pthread_mutex_unlock(&list_lock);
return -EINVAL;
@@ -1191,10 +1100,8 @@
if (g_binder_enabled) {
if (!g_qas_died) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
return qas->qahw_get_version();
} else {
return -ENODEV;
@@ -1208,12 +1115,11 @@
{
ALOGV("%d:%s",__LINE__, __func__);
if (g_binder_enabled) {
- if (!g_qas_died && (--g_qas_load_count == 0)) {
+ if (!g_qas_died && ((g_qas_load_count > 0) && (--g_qas_load_count == 0))) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return -ENODEV;
- }
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ pthread_mutex_destroy(&list_lock);
return qas->qahw_unload_module(hw_module);
} else {
return -ENODEV;
@@ -1232,10 +1138,8 @@
ALOGV("%d:%s: g_binder_enabled %d",__LINE__, __func__, g_binder_enabled);
if (g_binder_enabled) {
sp<Iqti_audio_server> qas = get_qti_audio_server();
- if (qas == 0) {
- ALOGE("%d:%s: invalid HAL handle",__LINE__, __func__);
- return (void*)(-ENODEV);
- }
+ if (qas_status(qas) == -1)
+ return (void*)(-ENODEV);
g_qas_handle = qas->qahw_load_module(hw_module_id);
if (g_qas_handle == NULL) {
ALOGE("%s: HAL loading failed", __func__);
@@ -1254,6 +1158,178 @@
}
return g_qas_handle;
}
+
+/* Audio effects API */
+qahw_effect_lib_handle_t qahw_effect_load_library(const char *lib_name)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return NULL;
+ return qas->qahw_effect_load_library(lib_name);
+ } else {
+ return NULL;
+ }
+ } else {
+ return qahw_effect_load_library_l(lib_name);
+ }
+}
+
+int32_t qahw_effect_unload_library(qahw_effect_lib_handle_t handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_unload_library(handle);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_unload_library_l(handle);
+ }
+}
+
+int32_t qahw_effect_create(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ int32_t io_handle,
+ qahw_effect_handle_t *effect_handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_create(handle, uuid, io_handle, effect_handle);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_create_l(handle, uuid, io_handle, effect_handle);
+ }
+}
+
+int32_t qahw_effect_release(qahw_effect_lib_handle_t handle,
+ qahw_effect_handle_t effect_handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_release(handle, effect_handle);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_release_l(handle, effect_handle);
+ }
+}
+
+int32_t qahw_effect_get_descriptor(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ qahw_effect_descriptor_t *effect_desc)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_get_descriptor(handle, uuid, effect_desc);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_get_descriptor_l(handle, uuid, effect_desc);
+ }
+}
+
+int32_t qahw_effect_get_version()
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_get_version();
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_get_version_l();
+ }
+}
+
+int32_t qahw_effect_process(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_process(self, in_buffer, out_buffer);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_process_l(self, in_buffer, out_buffer);
+ }
+}
+
+int32_t qahw_effect_command(qahw_effect_handle_t self,
+ uint32_t cmd_code,
+ uint32_t cmd_size,
+ void *cmd_data,
+ uint32_t *reply_size,
+ void *reply_data)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_command(self, cmd_code, cmd_size, cmd_data,
+ reply_size, reply_data);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_command_l(self, cmd_code, cmd_size, cmd_data,
+ reply_size, reply_data);
+ }
+}
+
+int32_t qahw_effect_process_reverse(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ if (g_binder_enabled) {
+ if (!g_qas_died) {
+ sp<Iqti_audio_server> qas = get_qti_audio_server();
+ if (qas_status(qas) == -1)
+ return -ENODEV;
+ return qas->qahw_effect_process_reverse(self, in_buffer, out_buffer);
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ return qahw_effect_process_reverse_l(self, in_buffer, out_buffer);
+ }
+}
+
#else
void qahw_register_qas_death_notify_cb(audio_error_callback cb __unused, void* context __unused)
{
@@ -1524,6 +1600,78 @@
return qahw_set_param_data_l(hw_module, param_id, payload);
}
+/* Audio effects API */
+qahw_effect_lib_handle_t qahw_effect_load_library(const char *lib_path)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_load_library_l(lib_path);
+}
+
+int32_t qahw_effect_unload_library(qahw_effect_lib_handle_t handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_unload_library_l(handle);
+}
+
+int32_t qahw_effect_create(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ int32_t io_handle,
+ qahw_effect_handle_t *effect_handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_create_l(handle, uuid, io_handle, effect_handle);
+}
+
+int32_t qahw_effect_release(qahw_effect_lib_handle_t handle,
+ qahw_effect_handle_t effect_handle)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_release_l(handle, effect_handle);
+}
+
+int32_t qahw_effect_get_descriptor(qahw_effect_lib_handle_t handle,
+ const qahw_effect_uuid_t *uuid,
+ qahw_effect_descriptor_t *effect_desc)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_get_descriptor_l(handle, uuid, effect_desc);
+}
+
+int32_t qahw_effect_get_version()
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_get_version_l();
+}
+
+int32_t qahw_effect_process(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_process_l(self, in_buffer, out_buffer);
+}
+
+int32_t qahw_effect_command(qahw_effect_handle_t self,
+ uint32_t cmd_code,
+ uint32_t cmd_size,
+ void *cmd_data,
+ uint32_t *reply_size,
+ void *reply_data)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_command_l(self, cmd_code, cmd_size,
+ cmd_data, reply_size, reply_data);
+}
+
+int32_t qahw_effect_process_reverse(qahw_effect_handle_t self,
+ qahw_audio_buffer_t *in_buffer,
+ qahw_audio_buffer_t *out_buffer)
+{
+ ALOGV("%d:%s",__LINE__, __func__);
+ return qahw_effect_process_reverse_l(self, in_buffer,
+ out_buffer);
+}
+
int qahw_create_audio_patch(qahw_module_handle_t *hw_module,
unsigned int num_sources,
const struct audio_port_config *sources,