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

Commit 9983c375 authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Gerrit - the friendly Code Review server
Browse files

hal: avoid undesired backend reconfiguration for multi-record usecase

Backend is getting reconfigured if new session is started with
configuration not matching to the current configuration
even though new configuration is inferior to the current
configuration and the session requesting superior configuration
is still active.
Fix this issue by checking configurations from other active sessions
before reconfiguring backend.

Change-Id: I5727c4de306a7e57ad9c4cf0d5f659f9420837af
parent ac1de01d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -280,8 +280,8 @@ struct stream_in {
    char profile[MAX_STREAM_PROFILE_STR_LEN];
    bool is_st_session;
    bool is_st_session_active;
    int sample_rate;
    int bit_width;
    unsigned int sample_rate;
    unsigned int bit_width;
    bool realtime;
    int af_period_multiplier;
    struct stream_app_type_cfg app_type_cfg;
+27 −0
Original line number Diff line number Diff line
@@ -5477,6 +5477,33 @@ static bool platform_check_capture_codec_backend_cfg(struct audio_device* adev,
              __func__);
        bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
        sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
    } else {
        struct listnode *node;
        struct audio_usecase *uc = NULL;
        unsigned int uc_channels = 0;
        struct stream_in *in = NULL;
        /* update cfg against other existing capture usecases on same backend */
        list_for_each(node, &adev->usecase_list) {
            uc = node_to_item(node, struct audio_usecase, list);
            if (uc->type == PCM_CAPTURE &&
                backend_idx == platform_get_backend_index(uc->in_snd_device)) {
                in = (struct stream_in *) uc->stream.in;
                uc_channels = audio_channel_count_from_in_mask(in->channel_mask);

                ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",
                      __func__, use_case_table[uc->id], uc->id, in->sample_rate,
                      in->bit_width, uc_channels,
                      platform_get_snd_device_name(uc->in_snd_device));

                if (sample_rate < in->sample_rate)
                    sample_rate = in->sample_rate;
                if (bit_width < in->bit_width)
                    bit_width = in->bit_width;
                if (channels < uc_channels)
                    channels = uc_channels;
            }
        }
    }
    if (backend_idx == USB_AUDIO_TX_BACKEND) {
        audio_extn_usb_is_config_supported(&bit_width, &sample_rate, &channels, false);
+27 −0
Original line number Diff line number Diff line
@@ -5351,6 +5351,33 @@ static bool platform_check_capture_codec_backend_cfg(struct audio_device* adev,
              "for unprocessed/camera source", __func__);
        bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
        sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
    } else {
        struct listnode *node;
        struct audio_usecase *uc = NULL;
        unsigned int uc_channels = 0;
        struct stream_in *in = NULL;
        /* update cfg against other existing capture usecases on same backend */
        list_for_each(node, &adev->usecase_list) {
            uc = node_to_item(node, struct audio_usecase, list);
            if (uc->type == PCM_CAPTURE &&
                backend_idx == platform_get_backend_index(uc->in_snd_device)) {
                in = (struct stream_in *) uc->stream.in;
                uc_channels = audio_channel_count_from_in_mask(in->channel_mask);

                ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",
                      __func__, use_case_table[uc->id], uc->id, in->sample_rate,
                      in->bit_width, uc_channels,
                      platform_get_snd_device_name(uc->in_snd_device));

                if (sample_rate < in->sample_rate)
                    sample_rate = in->sample_rate;
                if (bit_width < in->bit_width)
                    bit_width = in->bit_width;
                if (channels < uc_channels)
                    channels = uc_channels;
            }
        }
    }
    if (backend_idx == USB_AUDIO_TX_BACKEND) {
        audio_extn_usb_is_config_supported(&bit_width, &sample_rate, &channels, false);