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

Commit 990de555 authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Gerrit - the friendly Code Review server
Browse files

hal: Send A2DP backend config for each routed stream

There exists a corner case where A2DP backend config is not
sent after BE is closed and reopened leading to slimbus
running at default rate. This happens because A2DP snd_device
is already active, hence backend config for A2DP is not sent.
However, audio route is disabled and enabled i.e. BE is closed
and reopened. Thus, slimbus is configured at 8 KHz which is a
problem for A2DP.
Fix this by sending backend config for each stream that gets
routed to A2DP and A2DP snd_device is enabled.

Change-Id: I3edfcaaac9d0bc81f7be4090f8057f3947b1e5d0
parent 43b18e0b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1303,6 +1303,14 @@ fail:
    return is_configured;
}

bool a2dp_set_source_backend_cfg()
{
    if (a2dp.a2dp_source_started && !a2dp.a2dp_source_suspended)
        return a2dp_set_backend_cfg(SOURCE);

    return false;
}

bool configure_aac_dec_format(audio_aac_dec_config_t *aac_bt_cfg)
{
    struct mixer_ctl *ctl_dec_data = NULL, *ctrl_bit_format = NULL;
+14 −1
Original line number Diff line number Diff line
@@ -4641,6 +4641,9 @@ static a2dp_start_capture_t a2dp_start_capture;
typedef int (*a2dp_stop_capture_t)();
static a2dp_stop_capture_t a2dp_stop_capture;

typedef bool (*a2dp_set_source_backend_cfg_t)();
static a2dp_set_source_backend_cfg_t a2dp_set_source_backend_cfg;

typedef int (*sco_start_configuration_t)();
static sco_start_configuration_t sco_start_configuration;

@@ -4695,7 +4698,10 @@ int a2dp_offload_feature_init(bool is_feature_enabled)
            !(a2dp_start_capture =
                 (a2dp_start_capture_t)dlsym(a2dp_lib_handle, "a2dp_start_capture")) ||
            !(a2dp_stop_capture =
                 (a2dp_stop_capture_t)dlsym(a2dp_lib_handle, "a2dp_stop_capture"))) {
                 (a2dp_stop_capture_t)dlsym(a2dp_lib_handle, "a2dp_stop_capture")) ||
            !(a2dp_set_source_backend_cfg =
                 (a2dp_set_source_backend_cfg_t)dlsym(
                                     a2dp_lib_handle, "a2dp_set_source_backend_cfg"))) {
            ALOGE("%s: dlsym failed", __func__);
            goto feature_disabled;
        }
@@ -4733,6 +4739,7 @@ feature_disabled:
    a2dp_source_is_suspended = NULL;
    a2dp_start_capture = NULL;
    a2dp_stop_capture = NULL;
    a2dp_set_source_backend_cfg = NULL;

    ALOGW(":: %s: ---- Feature A2DP_OFFLOAD is disabled ----", __func__);
    return -ENOSYS;
@@ -4831,6 +4838,12 @@ int audio_extn_a2dp_stop_capture()
    return (a2dp_stop_capture ? a2dp_stop_capture() : 0);
}

bool audio_extn_a2dp_set_source_backend_cfg()
{
    return (a2dp_set_source_backend_cfg ?
                a2dp_set_source_backend_cfg() : false);
}

int audio_extn_sco_start_configuration()
{
    return (sco_start_configuration? sco_start_configuration() : 0);
+1 −0
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@ bool audio_extn_a2dp_source_is_ready();
bool audio_extn_a2dp_source_is_suspended();
int audio_extn_a2dp_start_capture();
int audio_extn_a2dp_stop_capture();
bool audio_extn_a2dp_set_source_backend_cfg();
int audio_extn_sco_start_configuration();
void audio_extn_sco_reset_configuration();

+5 −0
Original line number Diff line number Diff line
@@ -1387,6 +1387,11 @@ int enable_snd_device(struct audio_device *adev,
                                       new_snd_devices) != 0)) {
        ALOGV("%s: snd_device(%d: %s) is already active",
              __func__, snd_device, device_name);
        /* Set backend config for A2DP to ensure slimbus configuration
           is correct if A2DP is already active and backend is closed
           and re-opened */
        if (snd_device == SND_DEVICE_OUT_BT_A2DP)
            audio_extn_a2dp_set_source_backend_cfg();
        return 0;
    }