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

Commit bce652a6 authored by Vignesh Kulothungan's avatar Vignesh Kulothungan Committed by android-build-merger
Browse files

audio: Add support for DSDS for incall music feature

am: 3ff76895

Change-Id: I376394ad9eb5360325598685b081efc65b5c5be1
parents 75f07c9a 3ff76895
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = {
    [USECASE_AUDIO_RECORD_VOIP] = "audio-record-voip",

    [USECASE_INCALL_MUSIC_UPLINK] = "incall-music-uplink",
    [USECASE_INCALL_MUSIC_UPLINK2] = "incall-music-uplink2",

    [USECASE_AUDIO_A2DP_ABR_FEEDBACK] = "a2dp-abr-feedback",
};
@@ -1725,7 +1726,8 @@ int select_devices_with_force_switch(struct audio_device *adev,
            out_snd_device = SND_DEVICE_OUT_SPEAKER;
    }

    if (usecase->id == USECASE_INCALL_MUSIC_UPLINK) {
    if (usecase->id == USECASE_INCALL_MUSIC_UPLINK ||
        usecase->id == USECASE_INCALL_MUSIC_UPLINK2) {
        out_snd_device = SND_DEVICE_OUT_VOICE_MUSIC_TX;
    }

@@ -2338,8 +2340,10 @@ static int stop_output_stream(struct stream_out *out)
        audio_low_latency_hint_end();
    }

    if (out->usecase == USECASE_INCALL_MUSIC_UPLINK)
    if (out->usecase == USECASE_INCALL_MUSIC_UPLINK ||
        out->usecase == USECASE_INCALL_MUSIC_UPLINK2) {
        voice_set_device_mute_flag(adev, false);
    }

    /* 1. Get and set stream specific mixer controls */
    disable_audio_route(adev, uc_info);
@@ -2444,6 +2448,16 @@ int start_output_stream(struct stream_out *out)
        goto error_config;
    }

    //Update incall music usecase to reflect correct voice session
    if (out->flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) {
        ret = voice_extn_check_and_set_incall_music_usecase(adev, out);
        if (ret != 0) {
            ALOGE("%s: Incall music delivery usecase cannot be set error:%d",
                __func__, ret);
            goto error_config;
        }
    }

    if (out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) {
        if (!audio_extn_a2dp_is_ready()) {
            if (out->devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
@@ -2506,8 +2520,10 @@ int start_output_stream(struct stream_out *out)

    audio_extn_extspk_update(adev->extspk);

    if (out->usecase == USECASE_INCALL_MUSIC_UPLINK)
    if (out->usecase == USECASE_INCALL_MUSIC_UPLINK ||
        out->usecase == USECASE_INCALL_MUSIC_UPLINK2) {
        voice_set_device_mute_flag(adev, true);
    }

    ALOGV("%s: Opening PCM device card_id(%d) device_id(%d) format(%#x)",
          __func__, adev->snd_card, out->pcm_device_id, out->config.format);
@@ -3502,7 +3518,9 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
            if (out->muted)
                memset((void *)buffer, 0, bytes);
            // FIXME: this can be removed once audio flinger mixer supports mono output
            if (out->usecase == USECASE_AUDIO_PLAYBACK_VOIP || out->usecase == USECASE_INCALL_MUSIC_UPLINK) {
            if (out->usecase == USECASE_AUDIO_PLAYBACK_VOIP ||
                out->usecase == USECASE_INCALL_MUSIC_UPLINK ||
                out->usecase == USECASE_INCALL_MUSIC_UPLINK2) {
                size_t channel_count = audio_channel_count_from_out_mask(out->channel_mask);
                int16_t *src = (int16_t *)buffer;
                int16_t *dst = (int16_t *)buffer;
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ enum {
    USECASE_AUDIO_RECORD_VOIP,

    USECASE_INCALL_MUSIC_UPLINK,
    USECASE_INCALL_MUSIC_UPLINK2,

    USECASE_AUDIO_A2DP_ABR_FEEDBACK,

+3 −0
Original line number Diff line number Diff line
@@ -251,6 +251,8 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = {

    [USECASE_INCALL_MUSIC_UPLINK] = {INCALL_MUSIC_UPLINK_PCM_DEVICE,
                                     INCALL_MUSIC_UPLINK_PCM_DEVICE},
    [USECASE_INCALL_MUSIC_UPLINK2] = {INCALL_MUSIC_UPLINK2_PCM_DEVICE,
                                     INCALL_MUSIC_UPLINK2_PCM_DEVICE},
};

/* Array to store sound devices */
@@ -712,6 +714,7 @@ static const struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_VOIP)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD_VOIP)},
    {TO_NAME_INDEX(USECASE_INCALL_MUSIC_UPLINK)},
    {TO_NAME_INDEX(USECASE_INCALL_MUSIC_UPLINK2)},
    {TO_NAME_INDEX(USECASE_AUDIO_A2DP_ABR_FEEDBACK)},
};

+1 −0
Original line number Diff line number Diff line
@@ -336,6 +336,7 @@ enum {
#define AFE_PROXY_RECORD_PCM_DEVICE 8

#define INCALL_MUSIC_UPLINK_PCM_DEVICE 27
#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 27

#define HFP_PCM_RX 5
#ifdef PLATFORM_MSM8x26
+10 −1
Original line number Diff line number Diff line
@@ -576,7 +576,16 @@ void voice_extn_get_parameters(const struct audio_device *adev,
int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                  struct stream_out *out)
{
    uint32_t session_id = get_session_id_with_state(adev, CALL_ACTIVE);
    if (session_id == VOICEMMODE1_VSID)
        out->usecase = USECASE_INCALL_MUSIC_UPLINK;
    else if (session_id == VOICEMMODE2_VSID)
        out->usecase = USECASE_INCALL_MUSIC_UPLINK2;
    else {
        ALOGE("%s: Invalid session id %x", __func__, session_id);
        out->usecase = USECASE_INCALL_MUSIC_UPLINK;
    }

    out->config = pcm_config_incall_music;
    //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
    out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;