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

Commit 18ac4e97 authored by Weiyin Jiang's avatar Weiyin Jiang
Browse files

hal: enable wma/wmapro offload

Add wma specific parameters as to enable wma offloading.

Change-Id: Icdda981dd62c670cef6d4172cab2aeca6381c2af
parent 52f8653d
Loading
Loading
Loading
Loading
+55 −1
Original line number Diff line number Diff line
@@ -279,7 +279,9 @@ static bool is_supported_format(audio_format_t format)
        format == AUDIO_FORMAT_AAC_HE_V2 ||
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_FLAC)
        format == AUDIO_FORMAT_FLAC ||
        format == AUDIO_FORMAT_WMA ||
        format == AUDIO_FORMAT_WMA_PRO)
           return true;

    return false;
@@ -302,6 +304,12 @@ static int get_snd_codec_id(audio_format_t format)
    case AUDIO_FORMAT_FLAC:
        id = SND_AUDIOCODEC_FLAC;
        break;
    case AUDIO_FORMAT_WMA:
        id = SND_AUDIOCODEC_WMA;
        break;
    case AUDIO_FORMAT_WMA_PRO:
        id = SND_AUDIOCODEC_WMA_PRO;
        break;
    default:
        ALOGE("%s: Unsupported audio format :%x", __func__, format);
    }
@@ -1790,6 +1798,52 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par
        }
    }

    if (out->format == AUDIO_FORMAT_WMA || out->format == AUDIO_FORMAT_WMA_PRO) {
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_FORMAT_TAG, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->format = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_BLOCK_ALIGN, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.super_block_align = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_BIT_PER_SAMPLE, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.bits_per_sample = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_CHANNEL_MASK, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.channelmask = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.encodeopt = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION1, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.encodeopt1 = atoi(value);
            out->send_new_metadata = 1;
        }
        ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_WMA_ENCODE_OPTION2, value, sizeof(value));
        if (ret >= 0) {
            out->compr_config.codec->options.wma.encodeopt2 = atoi(value);
            out->send_new_metadata = 1;
        }
        ALOGV("WMA params: fmt %x, balgn %x, sr %d, chmsk %x, encop %x, op1 %x, op2 %x",
              out->compr_config.codec->format,
              out->compr_config.codec->options.wma.super_block_align,
              out->compr_config.codec->options.wma.bits_per_sample,
              out->compr_config.codec->options.wma.channelmask,
              out->compr_config.codec->options.wma.encodeopt,
              out->compr_config.codec->options.wma.encodeopt1,
              out->compr_config.codec->options.wma.encodeopt2);
    }

    ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_SAMPLE_RATE, value, sizeof(value));
    if(ret >= 0)
        is_meta_data_params = true;