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

Commit 2b1ba557 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4778776 from 5a333c11 to pi-release

Change-Id: I9520d1fb4e4750975ae22e9106ee1553de039c20
parents 9f9942e0 5a333c11
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -1496,7 +1496,11 @@ void audio_extn_a2dp_set_parameters(struct str_parms *parms)
     ret = str_parms_get_str(parms, "A2dpSuspended", value, sizeof(value));
     if (ret >= 0) {
         if (a2dp.bt_lib_handle && (a2dp.bt_state != A2DP_STATE_DISCONNECTED)) {
             if ((!strncmp(value, "true", sizeof(value))) && !a2dp.a2dp_suspended) {
             if (strncmp(value, "true", sizeof(value)) == 0) {
                if (a2dp.a2dp_suspended) {
                    ALOGD("%s: A2DP is already suspended", __func__);
                    goto param_handled;
                }
                ALOGD("%s: Setting A2DP to suspend state", __func__);
                a2dp.a2dp_suspended = true;
                list_for_each(node, &a2dp.adev->usecase_list) {
@@ -1509,14 +1513,20 @@ void audio_extn_a2dp_set_parameters(struct str_parms *parms)
                    }
                }
                reset_a2dp_enc_config_params();
                if (a2dp.audio_stream_suspend)
                if (a2dp.audio_stream_suspend) {
                   a2dp.audio_stream_suspend();
            } else if (a2dp.a2dp_suspended) {
                }
            } else {
                if (!a2dp.a2dp_suspended) {
                    ALOGD("%s: A2DP is already unsuspended", __func__);
                    goto param_handled;
                }
                ALOGD("%s: Resetting A2DP suspend state", __func__);
                struct audio_usecase *uc_info;
                struct listnode *node;
                if (a2dp.clear_a2dp_suspend_flag)
                if (a2dp.clear_a2dp_suspend_flag) {
                    a2dp.clear_a2dp_suspend_flag();
                }
                a2dp.a2dp_suspended = false;
                /*
                 * It is possible that before suspend, A2DP sessions can be active.
+2 −2
Original line number Diff line number Diff line
@@ -4086,9 +4086,9 @@ static int in_get_active_microphones(const struct audio_stream_in *stream,

    lock_input_stream(in);
    pthread_mutex_lock(&adev->lock);
    int ret = platform_get_active_microphones(adev->platform, in->device,
    int ret = platform_get_active_microphones(adev->platform,
                                              audio_channel_count_from_in_mask(in->channel_mask),
                                              in->source, in->usecase, mic_array, mic_count);
                                              in->usecase, mic_array, mic_count);
    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&in->lock);

+7 −4
Original line number Diff line number Diff line
@@ -2504,10 +2504,13 @@ int platform_get_microphones(void *platform __unused,
    return -ENOSYS;
}

int platform_get_active_microphones(void *platform __unused,
                                    audio_devices_t device __unused,
                                    unsigned int channels __unused,
                                    int source __unused, audio_usecase_t usecase __unused,
bool platform_set_microphone_map(void *platform __unused, snd_device_t in_snd_device __unused,
                                 const struct mic_info *info __unused) {
    return false;
}

int platform_get_active_microphones(void *platform __unused, unsigned int channels __unused,
                                    audio_usecase_t usecase __unused,
                                    struct audio_microphone_characteristic_t *mic_array __unused,
                                    size_t *mic_count __unused) {
    return -ENOSYS;
+2 −4
Original line number Diff line number Diff line
@@ -1353,10 +1353,8 @@ int platform_get_microphones(void *platform __unused,
    return -ENOSYS;
}

int platform_get_active_microphones(void *platform __unused,
                                    audio_devices_t device __unused,
                                    unsigned int channels __unused,
                                    int source __unused, audio_usecase_t usecase __unused,
int platform_get_active_microphones(void *platform __unused, unsigned int channels __unused,
                                    audio_usecase_t usecase __unused,
                                    struct audio_microphone_characteristic_t *mic_array __unused,
                                    size_t *mic_count __unused) {
    return -ENOSYS;
+53 −21
Original line number Diff line number Diff line
@@ -105,6 +105,11 @@ struct be_dai_name_struct {
    char be_name[BE_DAI_NAME_MAX_LENGTH];
};

struct snd_device_to_mic_map {
    struct mic_info microphones[AUDIO_MICROPHONE_MAX_COUNT];
    size_t mic_count;
};

static struct listnode operator_info_list;
static struct listnode *operator_specific_device_table[SND_DEVICE_MAX];

@@ -167,6 +172,7 @@ struct platform_data {

    uint32_t declared_mic_count;
    struct audio_microphone_characteristic_t microphones[AUDIO_MICROPHONE_MAX_COUNT];
    struct snd_device_to_mic_map mic_map[SND_DEVICE_MAX];
};

static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
@@ -4547,38 +4553,64 @@ int platform_get_microphones(void *platform,
    return 0;
}

int platform_get_active_microphones(void *platform, audio_devices_t device, unsigned int channels,
                                    int source __unused, audio_usecase_t usecase __unused,
bool platform_set_microphone_map(void *platform, snd_device_t in_snd_device,
                                 const struct mic_info *info) {
    struct platform_data *my_data = (struct platform_data *)platform;
    if (in_snd_device < SND_DEVICE_IN_BEGIN || in_snd_device >= SND_DEVICE_IN_END) {
        ALOGE("%s: Sound device not valid", __func__);
        return false;
    }
    size_t m_count = my_data->mic_map[in_snd_device].mic_count++;
    if (m_count >= AUDIO_MICROPHONE_MAX_COUNT) {
        ALOGE("%s: Microphone count is greater than max allowed value", __func__);
        my_data->mic_map[in_snd_device].mic_count--;
        return false;
    }
    my_data->mic_map[in_snd_device].microphones[m_count] = *info;
    return true;
}

int platform_get_active_microphones(void *platform, unsigned int channels,
                                    audio_usecase_t uc_id,
                                    struct audio_microphone_characteristic_t *mic_array,
                                    size_t *mic_count) {
    struct platform_data *my_data = (struct platform_data *)platform;
    if (mic_count == NULL) {
        return -EINVAL;
    }
    if (mic_array == NULL) {
    struct audio_usecase *usecase = get_usecase_from_list(my_data->adev, uc_id);
    if (mic_count == NULL || mic_array == NULL || usecase == NULL) {
        return -EINVAL;
    }
    size_t max_mic_count = my_data->declared_mic_count;
    size_t actual_mic_count = 0;

    if (*mic_count == 0) {
        // TODO: return declared mic count as a preliminary implementation, the final
        // implementation will derive mic count and channel mapping from use case, source and device
        *mic_count = my_data->declared_mic_count;
        return 0;
    snd_device_t active_input_snd_device =
            platform_get_input_snd_device(platform, usecase->stream.in->device);
    if (active_input_snd_device == SND_DEVICE_NONE) {
        ALOGI("%s: No active microphones found", __func__);
        goto end;
    }

    size_t max_mic_count = *mic_count;
    size_t actual_mic_count = 0;
    for (size_t i = 0; i < max_mic_count && i < my_data->declared_mic_count; i++) {
        // TODO: get actual microphone and channel mapping type.
        if ((my_data->microphones[i].device & device) == device) {
            mic_array[actual_mic_count] = my_data->microphones[i];
            for (size_t ch = 0; ch < channels; ch++) {
    size_t  active_mic_count = my_data->mic_map[active_input_snd_device].mic_count;
    struct mic_info *m_info = my_data->mic_map[active_input_snd_device].microphones;

    for (size_t i = 0; i < active_mic_count; i++) {
        unsigned int channels_for_active_mic = channels;
        if (channels_for_active_mic > m_info[i].channel_count) {
            channels_for_active_mic = m_info[i].channel_count;
        }
        for (size_t j = 0; j < max_mic_count; j++) {
            if (strcmp(my_data->microphones[j].device_id,
                       m_info[i].device_id) == 0) {
                mic_array[actual_mic_count] = my_data->microphones[j];
                for (size_t ch = 0; ch < channels_for_active_mic; ch++) {
                     mic_array[actual_mic_count].channel_mapping[ch] =
                        AUDIO_MICROPHONE_CHANNEL_MAPPING_DIRECT;
                             m_info[i].channel_mapping[ch];
                }
                actual_mic_count++;
                break;
            }
        }
    }
end:
    *mic_count = actual_mic_count;
    return 0;
}
Loading