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

Commit d6834efd authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Eric Laurent
Browse files

hal: Add support to handle A2DP codec config

Add support in audio HAL to respond for A2DP codec
config query from framework.

Bug: 79476124
Test: music playback over BT A2DP
Change-Id: I1dd010d7a723ef289efb0e825d094c7d64e06ee3
parent 5a333c11
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -1370,7 +1370,6 @@ int audio_extn_a2dp_start_playback()
        ALOGD("%s: calling Bluetooth module stream start", __func__);
        /* This call indicates Bluetooth IPC lib to start playback */
        ret =  a2dp.audio_stream_start();
        ALOGE("%s: Bluetooth controller start return = %d", __func__, ret);
        if (ret != 0 ) {
           ALOGE("%s: Bluetooth controller start failed", __func__);
           a2dp.a2dp_started = false;
@@ -1457,16 +1456,17 @@ int audio_extn_a2dp_stop_playback()
    return 0;
}

void audio_extn_a2dp_set_parameters(struct str_parms *parms)
int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
{
     int ret, val;
     int ret = 0, val;
     char value[32] = {0};
     struct audio_usecase *uc_info;
     struct listnode *node;

     if (a2dp.is_a2dp_offload_enabled == false) {
        ALOGV("%s: No supported encoders identified,ignoring A2DP setparam", __func__);
        return;
        ret = -EINVAL;
        goto param_handled;
     }

     ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value,
@@ -1562,8 +1562,20 @@ void audio_extn_a2dp_set_parameters(struct str_parms *parms)
        }
        goto param_handled;
     }

     ret = str_parms_get_str(parms, AUDIO_PARAMETER_RECONFIG_A2DP, value,
                         sizeof(value));
     if (ret >= 0) {
         if (a2dp.is_a2dp_offload_enabled &&
                a2dp.bt_state != A2DP_STATE_DISCONNECTED) {
             *reconfig = true;
         }
         goto param_handled;
     }

param_handled:
     ALOGV("%s: end of A2DP setparam", __func__);
     return ret;
}

void audio_extn_a2dp_set_handoff_mode(bool is_on)
@@ -1664,4 +1676,21 @@ uint32_t audio_extn_a2dp_get_encoder_latency()
    }
    return latency;
}

int audio_extn_a2dp_get_parameters(struct str_parms *query,
                                   struct str_parms *reply)
{
    int ret, val = 0;
    char value[32]={0};

    ret = str_parms_get_str(query, AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED,
                            value, sizeof(value));
    if (ret >= 0) {
        val = a2dp.is_a2dp_offload_enabled;
        str_parms_add_int(reply, AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED, val);
        ALOGV("%s: called ... isReconfigA2dpSupported %d", __func__, val);
    }

    return 0;
}
#endif // A2DP_OFFLOAD_ENABLED
+5 −2
Original line number Diff line number Diff line
@@ -147,7 +147,8 @@ int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
#define audio_extn_a2dp_init(adev)                       (0)
#define audio_extn_a2dp_start_playback()                 (0)
#define audio_extn_a2dp_stop_playback()                  (0)
#define audio_extn_a2dp_set_parameters(parms)            (0)
#define audio_extn_a2dp_set_parameters(parms, reconfig)  (0)
#define audio_extn_a2dp_get_parameters(query, reply)     (0)
#define audio_extn_a2dp_is_force_device_switch()         (0)
#define audio_extn_a2dp_set_handoff_mode(is_on)          (0)
#define audio_extn_a2dp_get_sample_rate(sample_rate)     (0)
@@ -158,7 +159,9 @@ int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
void audio_extn_a2dp_init(void *adev);
int audio_extn_a2dp_start_playback();
int audio_extn_a2dp_stop_playback();
void audio_extn_a2dp_set_parameters(struct str_parms *parms);
int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig);
int audio_extn_a2dp_get_parameters(struct str_parms *query,
                                   struct str_parms *reply);
bool audio_extn_a2dp_is_force_device_switch();
void audio_extn_a2dp_set_handoff_mode(bool is_on);
void audio_extn_a2dp_get_sample_rate(int *sample_rate);
+6 −5
Original line number Diff line number Diff line
@@ -4643,6 +4643,7 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
    int val;
    int ret;
    int status = 0;
    bool a2dp_reconfig = false;

    ALOGV("%s: enter: %s", __func__, kvpairs);

@@ -4741,18 +4742,16 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
    }

    audio_extn_hfp_set_parameters(adev, parms);
    audio_extn_a2dp_set_parameters(parms);
    audio_extn_ma_set_parameters(adev, parms);

    // reconfigure should be done only after updating A2DP state in audio extension
    ret = str_parms_get_str(parms,"reconfigA2dp", value, sizeof(value));
    if (ret >= 0) {
    status = audio_extn_a2dp_set_parameters(parms, &a2dp_reconfig);
    if (status >= 0 && a2dp_reconfig) {
        struct audio_usecase *usecase;
        struct listnode *node;
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if ((usecase->type == PCM_PLAYBACK) &&
                (usecase->devices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP)) {
                (usecase->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                ALOGD("%s: reconfigure A2DP... forcing device switch", __func__);

                pthread_mutex_unlock(&adev->lock);
@@ -4786,6 +4785,8 @@ static char* adev_get_parameters(const struct audio_hw_device *dev,
    pthread_mutex_lock(&adev->lock);

    voice_get_parameters(adev, query, reply);
    audio_extn_a2dp_get_parameters(query, reply);

    str = str_parms_to_str(reply);
    str_parms_destroy(query);
    str_parms_destroy(reply);