hal: Fix QAF compilation issues with clang
-Fix bunch of compiler errors/warnings for qaf.c with clang.
-Handle DIRECT_PCM flag in HAL to fix playback using QAF.
Change-Id: I38a787ac9451ac16cbb4938b5cd3406c94ecff00
diff --git a/hal/audio_extn/qaf.c b/hal/audio_extn/qaf.c
index ca83b1d..44d471c 100644
--- a/hal/audio_extn/qaf.c
+++ b/hal/audio_extn/qaf.c
@@ -129,6 +129,8 @@
FILE *fp_output_writer_hdmi = NULL;
#endif
+void set_hdmi_configuration_to_module();
+
struct qaf_adsp_hdlr_config_state {
struct audio_adsp_event event_params;
/* For holding client audio_adsp_event payload */
@@ -386,7 +388,7 @@
static int get_media_fmt_array_index_for_output_id(
struct qaf_module* qaf_mod,
- int output_id)
+ uint32_t output_id)
{
int i;
for (i = 0; i < MAX_QAF_MODULE_OUT; i++) {
@@ -496,7 +498,7 @@
{
DEBUG_MSG();
- int ret = 0, k;
+ int ret = 0;
struct stream_out *out = p_qaf->passthrough_in;
if (!out) return -EINVAL;
@@ -592,7 +594,7 @@
static int audio_extn_qaf_stream_stop(struct stream_out *out)
{
int ret = 0;
- DEBUG_MSG("Output Stream 0x%x", out);
+ DEBUG_MSG("Output Stream 0x%p", out);
if (!check_stream_state(out, RUN)) return ret;
@@ -837,7 +839,7 @@
return fragment_size;
}
-static uint32_t qaf_get_pcm_offload_input_buffer_size(info)
+static uint32_t qaf_get_pcm_offload_input_buffer_size(audio_offload_info_t* info)
{
return qaf_get_pcm_offload_buffer_size(info, MS12_PCM_IN_FRAGMENT_SIZE);
}
@@ -1132,21 +1134,22 @@
DEBUG_MSG("Output Stream %p", out);
lock_output_stream(out);
- //If QAF passthrough is active then block the flush on module input streams.
- if (p_qaf->passthrough_out) {
- pthread_mutex_lock(&p_qaf->lock);
- //If flush is received for the QAF passthrough stream then call the primary HAL api.
- if (p_qaf->passthrough_in == out) {
- status = p_qaf->passthrough_out->stream.flush(
- (struct audio_stream_out *)p_qaf->passthrough_out);
- out->offload_state = OFFLOAD_STATE_IDLE;
+ if (!out->standby) {
+ //If QAF passthrough is active then block the flush on module input streams.
+ if (p_qaf->passthrough_out) {
+ pthread_mutex_lock(&p_qaf->lock);
+ //If flush is received for the QAF passthrough stream then call the primary HAL api.
+ if (p_qaf->passthrough_in == out) {
+ status = p_qaf->passthrough_out->stream.flush(
+ (struct audio_stream_out *)p_qaf->passthrough_out);
+ out->offload_state = OFFLOAD_STATE_IDLE;
+ }
+ pthread_mutex_unlock(&p_qaf->lock);
+ } else {
+ //Flush the module input stream.
+ status = audio_extn_qaf_stream_flush(out);
}
- pthread_mutex_unlock(&p_qaf->lock);
- } else {
- //Flush the module input stream.
- status = audio_extn_qaf_stream_flush(out);
}
-
unlock_output_stream(out);
DEBUG_MSG("Exit");
return status;
@@ -1227,7 +1230,7 @@
if (media_fmt == NULL || out == NULL) {
return;
}
- struct audio_out_channel_map_param chmap = {0};
+ struct audio_out_channel_map_param chmap = {0,{0}};
int i = 0;
chmap.channels = media_fmt->channels;
for (i = 0; i < chmap.channels && i < AUDIO_CHANNEL_COUNT_MAX && i < AUDIO_QAF_MAX_CHANNELS;
@@ -1238,7 +1241,7 @@
}
/* Call back function for mm module. */
-static void notify_event_callback(audio_session_handle_t session_handle /*__unused*/,
+static void notify_event_callback(audio_session_handle_t session_handle __unused,
void *prv_data,
void *buf,
audio_event_id_t event_id,
@@ -1255,7 +1258,7 @@
1.Open compress device for HDMI(PCM or AC3) based on current hdmi o/p format and write
data to the HDMI device.
*/
- int ret, i;
+ int ret;
audio_output_flags_t flags;
struct qaf_module* qaf_mod = (struct qaf_module*)prv_data;
struct audio_stream_out *bt_stream = NULL;
@@ -1293,7 +1296,7 @@
audio_qaf_out_buffer_t *buf_payload = (audio_qaf_out_buffer_t*)buf;
int index = -1;
- if (size < sizeof(audio_qaf_out_buffer_t)) {
+ if ((uint32_t)size < sizeof(audio_qaf_out_buffer_t)) {
ERROR_MSG("AUDIO_DATA_EVENT_V2 payload size is not sufficient.");
return;
}
@@ -1338,7 +1341,7 @@
audio_qaf_media_format_t *p_cached_fmt = NULL;
int index = -1;
- if (size < sizeof(audio_qaf_media_format_t)) {
+ if ( (uint32_t)size < sizeof(audio_qaf_media_format_t)) {
ERROR_MSG("Size is not proper for the event AUDIO_OUTPUT_MEDIA_FORMAT_EVENT.");
return ;
}
@@ -1448,7 +1451,6 @@
/* CASE 2: Multi-Channel PCM output to HDMI.
* If any other HDMI output is already enabled then this has to be dropped.
*/
- bool create_mch_out_stream = false;
if (p_qaf->passthrough_enabled) {
//Closing all the multi-Channel PCM HDMI output stream from QAF.
@@ -1487,7 +1489,7 @@
}
devices = AUDIO_DEVICE_OUT_AUX_DIGITAL;
- flags = (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_DIRECT_PCM);
+ flags = AUDIO_OUTPUT_FLAG_DIRECT;
ret = adev_open_output_stream((struct audio_hw_device *)p_qaf->adev,
QAF_DEFAULT_COMPR_AUDIO_HANDLE,
@@ -1603,7 +1605,7 @@
devices = device;
}
- flags = (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_DIRECT_PCM);
+ flags = AUDIO_OUTPUT_FLAG_DIRECT;
/* TODO:: Need to Propagate errors to framework */
ret = adev_open_output_stream((struct audio_hw_device *)p_qaf->adev,
@@ -1855,7 +1857,7 @@
{
ALOGV("%s %d", __func__, __LINE__);
unsigned char* license_data = NULL;
- device_license_config_t lic_config = {0};
+ device_license_config_t lic_config = {NULL, 0, 0};
int ret = -ENOSYS, size = 0;
char value[PROPERTY_VALUE_MAX] = {0};
struct qaf_module *qaf_mod = NULL;
@@ -2264,9 +2266,8 @@
/* Sets the stream set parameters (device routing information). */
static int qaf_out_set_parameters(struct audio_stream *stream, const char *kvpairs)
{
- struct str_parms *parms, *new_parms;
+ struct str_parms *parms;
char value[32];
- char *new_kv_pairs;
int val = 0;
struct stream_out *out = (struct stream_out *)stream;
int ret = 0;
@@ -2410,7 +2411,7 @@
/*ADSP event is not supported for passthrough*/
if ((param_id == AUDIO_EXTN_PARAM_ADSP_STREAM_CMD)
- && !(new_out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM)) continue;
+ && !(new_out->flags == AUDIO_OUTPUT_FLAG_DIRECT)) continue;
if (new_out->standby)
new_out->stream.write((struct audio_stream_out *)new_out, NULL, 0);
lock_output_stream(new_out);
@@ -2427,8 +2428,7 @@
audio_extn_param_payload *payload)
{
int ret = -EINVAL, i;
- struct stream_out *new_out;
- struct audio_usecase *uc_info;
+ struct stream_out *new_out = NULL;
struct qaf_module *qaf_mod = get_qaf_module_for_input_stream(out);
if (!out || !qaf_mod || !payload) {
@@ -2521,7 +2521,7 @@
out->config.period_count = DEEP_BUFFER_OUTPUT_PERIOD_COUNT;
out->config.start_threshold = QAF_DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4;
out->config.avail_min = QAF_DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4;
- } else if(out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
+ } else if(out->flags == AUDIO_OUTPUT_FLAG_DIRECT) {
out->compr_config.fragment_size = qaf_get_pcm_offload_input_buffer_size(&(config->offload_info));
}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e5dc063..9656c83 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1483,7 +1483,9 @@
ssize_t count = audio_extn_usb_get_sup_sample_rates(is_playback,
supported_sample_rates,
max_rates);
- for (ssize_t i=0; i<count; i++) {
+ ssize_t i = 0;
+
+ for (i=0; i<count; i++) {
ALOGV("%s %s %d", __func__, is_playback ? "P" : "C",
supported_sample_rates[i]);
}
@@ -5467,8 +5469,8 @@
out->stream.pause = out_pause;
out->stream.resume = out_resume;
out->stream.flush = out_flush;
+ out->stream.set_callback = out_set_callback;
if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
- out->stream.set_callback = out_set_callback;
out->stream.drain = out_drain;
out->usecase = get_offload_usecase(adev, true /* is_compress */);
ALOGV("Compress Offload usecase .. usecase selected %d", out->usecase);