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

Commit d0a50b29 authored by Sharad Sangle's avatar Sharad Sangle Committed by Gerrit - the friendly Code Review server
Browse files

hal: route to speaker, when USB HS is unplugged

 When USB headset is disconnected the music playback paused
 and the policy manager send routing=0. If USB headset is
 connected before the standby time, AFE is not closed and opened,
 so routing to speker will guarantee AFE reconfiguration and
 AFE will be opend once USB is connected again, within standby
 time.

CRs-fixed: 2219129

Change-Id: I69985dda312de34e2c86c85ac448a722f7f31f42
parent 0d1a5592
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ int32_t audio_extn_get_afe_proxy_channel_count();
#define audio_extn_usb_get_sup_sample_rates(t, s, l)                   (0)
#define audio_extn_usb_is_tunnel_supported()                           (0)
#define audio_extn_usb_alive(adev)                                     (false)
#define audio_extn_usb_connected(parms)                                (0)
#undef USB_BURST_MODE_ENABLED
#else
void audio_extn_usb_init(void *adev);
@@ -241,6 +242,7 @@ int audio_extn_usb_get_max_bit_width(bool playback);
int audio_extn_usb_get_sup_sample_rates(int type, uint32_t *sr, uint32_t l);
bool audio_extn_usb_is_tunnel_supported();
bool audio_extn_usb_alive(int card);
bool audio_extn_usb_connected(struct str_parms *parms);
#endif

#ifndef USB_BURST_MODE_ENABLED
+20 −0
Original line number Diff line number Diff line
@@ -1430,6 +1430,26 @@ void audio_extn_usb_set_reconfig(bool is_required)
    usbmod->usb_reconfig = is_required;
}

bool audio_extn_usb_connected(struct str_parms *parms) {
    int card = -1;
    struct listnode *node_i = NULL;
    struct usb_card_config *usb_card_info = NULL;
    bool usb_connected = false;

    if (str_parms_get_int(parms, "card", &card) >= 0) {
        usb_connected = audio_extn_usb_alive(card);
    } else {
        list_for_each(node_i, &usbmod->usb_card_conf_list) {
            usb_card_info = node_to_item(node_i, struct usb_card_config, list);
            if (audio_extn_usb_alive(usb_card_info->usb_card)) {
                usb_connected = true;
                break;
            }
        }
    }
    return usb_connected;
}

void audio_extn_usb_init(void *adev)
{
    if (usbmod == NULL) {
+12 −0
Original line number Diff line number Diff line
@@ -3682,6 +3682,18 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
                !audio_extn_a2dp_is_ready()) {
                val = AUDIO_DEVICE_OUT_SPEAKER;
        }
        /*
        * When USB headset is disconnected the music platback paused
        * and the policy manager send routing=0. But if the USB is connected
        * back before the standby time, AFE is not closed and opened
        * when USB is connected back. So routing to speker will guarantee
        * AFE reconfiguration and AFE will be opend once USB is connected again
        */
        if ((out->devices & AUDIO_DEVICE_OUT_ALL_USB) &&
                (val == AUDIO_DEVICE_NONE) &&
                 !audio_extn_usb_connected(parms)) {
                 val = AUDIO_DEVICE_OUT_SPEAKER;
         }
        /* To avoid a2dp to sco overlapping / BT device improper state
         * check with BT lib about a2dp streaming support before routing
         */