Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4847e9de authored by Ashish Jain's avatar Ashish Jain Committed by Gerrit - the friendly Code Review server
Browse files

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
parent cc6a6e60
Loading
Loading
Loading
Loading
+32 −32
Original line number Diff line number Diff line
@@ -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 uint32_t get_pcm_output_buffer_size_samples(struct qaf_module *qaf_mod)

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 @@ static int create_qaf_passthrough_stream()
{
    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 qaf_send_offload_cmd_l(struct stream_out* out, int command)
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 @@ static uint32_t qaf_get_pcm_offload_buffer_size(audio_offload_info_t* info,
    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,6 +1134,7 @@ static int qaf_out_flush(struct audio_stream_out* stream)
    DEBUG_MSG("Output Stream %p", out);
    lock_output_stream(out);

    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);
@@ -1146,7 +1149,7 @@ static int qaf_out_flush(struct audio_stream_out* stream)
            //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 @@ static void set_out_stream_channel_map(struct stream_out *out, audio_qaf_media_f
    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 @@ static void set_out_stream_channel_map(struct stream_out *out, audio_qaf_media_f
}

/* 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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
     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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
        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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
        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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
            /* 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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
                }

                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 @@ static void notify_event_callback(audio_session_handle_t session_handle /*__unus
                    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 @@ static int audio_extn_qaf_session_open(mm_module_type mod_type, struct stream_ou
{
    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 @@ static int qaf_destroy_offload_callback_thread(struct stream_out *out)
/* 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 @@ int audio_extn_qaf_out_set_param_data(struct stream_out *out,

        /*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 @@ int audio_extn_qaf_out_get_param_data(struct stream_out *out,
                             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 @@ int audio_extn_qaf_open_output_stream(struct audio_hw_device *dev,
        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));
    }

+4 −2
Original line number Diff line number Diff line
@@ -1483,7 +1483,9 @@ static inline ssize_t read_usb_sup_sample_rates(bool is_playback __unused,
    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 @@ int adev_open_output_stream(struct audio_hw_device *dev,
        out->stream.pause = out_pause;
        out->stream.resume = out_resume;
        out->stream.flush = out_flush;
        if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
        out->stream.set_callback = out_set_callback;
        if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
            out->stream.drain = out_drain;
            out->usecase = get_offload_usecase(adev, true /* is_compress */);
            ALOGV("Compress Offload usecase .. usecase selected %d", out->usecase);