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

Commit ac203d58 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: Fix audio playback issue on USB headset"

parents 6afb9ced fae4211e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ static int usb_get_capability(char *type, int32_t *channels,
    char *read_buf, *str_start, *channel_start, *rates_str, *rates_str_for_val,
    *rates_str_start, *next_sr_str, *test, *next_sr_string, *temp_ptr;
    struct stat st;
    int rates_supported[size];
    int *rates_supported;
    char path[128];

    memset(&st, 0x0, sizeof(struct stat));
@@ -246,12 +246,14 @@ static int usb_get_capability(char *type, int32_t *channels,
        return -EINVAL;
    }

    rates_supported = (int *)malloc(sizeof(int) * size);
    next_sr_string = strtok_r(rates_str_for_val, " ,", &temp_ptr);
    if (next_sr_string == NULL) {
        ALOGE("%s: error could not get first rate val", __func__);
        close(fd);
        free(rates_str_for_val);
        free(rates_str);
        free(rates_supported);
        free(read_buf);
        return -EINVAL;
    }
@@ -282,6 +284,7 @@ static int usb_get_capability(char *type, int32_t *channels,
    close(fd);
    free(rates_str_for_val);
    free(rates_str);
    free(rates_supported);
    free(read_buf);
    return 0;
}
+36 −18
Original line number Diff line number Diff line
@@ -285,6 +285,14 @@ int disable_snd_device(struct audio_device *adev,

    adev->snd_dev_ref_cnt[snd_device]--;

    if(platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0) {
        ALOGE("%s: Invalid sound device returned", __func__);
        return -EINVAL;
    }

    if (adev->snd_dev_ref_cnt[snd_device] == 0) {
        ALOGV("%s: snd_device(%d: %s)", __func__,
              snd_device, device_name);
        /* exit usb play back thread */
        if(SND_DEVICE_OUT_USB_HEADSET == snd_device ||
           SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET == snd_device)
@@ -294,15 +302,8 @@ int disable_snd_device(struct audio_device *adev,
        if(SND_DEVICE_IN_USB_HEADSET_MIC == snd_device)
            audio_extn_usb_stop_capture(adev);

    if(platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0) {
        ALOGE("%s: Invalid sound device returned", __func__);
        return -EINVAL;
    }

    if (adev->snd_dev_ref_cnt[snd_device] == 0) {
        ALOGV("%s: snd_device(%d: %s)", __func__,
              snd_device, device_name);
        audio_route_reset_path(adev->audio_route, device_name);

        if (update_mixer)
            audio_route_update_mixer(adev->audio_route);
    }
@@ -1094,9 +1095,18 @@ static int check_input_parameters(uint32_t sample_rate,
                                  audio_format_t format,
                                  int channel_count)
{
    if (format != AUDIO_FORMAT_PCM_16_BIT) return -EINVAL;
    int ret = 0;

    if ((channel_count < 1) || (channel_count > 6)) return -EINVAL;
    if (format != AUDIO_FORMAT_PCM_16_BIT) ret = -EINVAL;

    switch (channel_count) {
    case 1:
    case 2:
    case 6:
        break;
    default:
        ret = -EINVAL;
    }

    switch (sample_rate) {
    case 8000:
@@ -1110,10 +1120,10 @@ static int check_input_parameters(uint32_t sample_rate,
    case 48000:
        break;
    default:
        return -EINVAL;
        ret = -EINVAL;
    }

    return 0;
    return ret;
}

static size_t get_input_buffer_size(uint32_t sample_rate,
@@ -2214,7 +2224,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
{
    struct audio_device *adev = (struct audio_device *)dev;
    struct stream_in *in;
    int ret, buffer_size, frame_size;
    int ret = 0, buffer_size, frame_size;
    int channel_count = popcount(config->channel_mask);

    ALOGV("%s: enter", __func__);
@@ -2251,9 +2261,17 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
    in->config = pcm_config_audio_capture;
    in->config.rate = config->sample_rate;

    if (audio_extn_ssr_get_enabled()&& channel_count == 6) {
        if(audio_extn_ssr_init(adev, in))
    if (channel_count == 6) {
        if(audio_extn_ssr_get_enabled()) {
            if(audio_extn_ssr_init(adev, in)) {
                ALOGE("%s: audio_extn_ssr_init failed", __func__);
                ret = -EINVAL;
                goto err_open;
            }
        } else {
            ret = -EINVAL;
            goto err_open;
        }
    } else {
        in->config.channels = channel_count;
        frame_size = audio_stream_frame_size((struct audio_stream *)in);
@@ -2265,7 +2283,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,

    *stream_in = &in->stream;
    ALOGV("%s: exit", __func__);
    return 0;
    return ret;

err_open:
    free(in);
+1 −1
Original line number Diff line number Diff line
@@ -858,7 +858,7 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
            if (audio_extn_ssr_get_enabled() && channel_count == 6)
                snd_device = SND_DEVICE_IN_QUAD_MIC;
            else if (channel_count > 1)
            else if (channel_count == 2)
                snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC;
            else
                snd_device = SND_DEVICE_IN_HANDSET_MIC;