/****************************************************************************
NAME	
	aghfpHandleSyncConnectInd

DESCRIPTION
	Incoming audio notification, accept if we recognise the sink reject
	otherwise.

RETURNS
	void
*/
void aghfpHandleSyncConnectInd(AGHFP *aghfp, const CL_DM_SYNC_CONNECT_IND_T *ind)
{
    uint16 i=0;
    uint16 my_audio = 0;
    uint16 num_sinks = 5;
    tp_bdaddr tp_addr = { {TYPED_BDADDR_PUBLIC, { 0, 0, 0 }}, TRANSPORT_BREDR_ACL};

    /* Sink array to store the sinks on the acl. */
    Sink *all_sinks = (Sink *)PanicNull(calloc(num_sinks, sizeof(Sink))); 

    tp_addr.taddr.addr = ind->bd_addr;

    if(StreamSinksFromBdAddr(&num_sinks, all_sinks, &tp_addr))
    {
        for (i=0; i<num_sinks; i++)
        {
            /* Make sure this profile instance owns the unlerlying sink */
            if (all_sinks[i] && all_sinks[i] == aghfp->rfcomm_sink)
            {
                my_audio = 1;
                break;
            }
        }
    }

    free(all_sinks);    

    /* If this is our audio connection then ask the app, otherwise reject outright */
    if (my_audio)
    {
        MAKE_AGHFP_MESSAGE(AGHFP_AUDIO_CONNECT_IND);
    	message->aghfp = aghfp;
		message->bd_addr = ind->bd_addr;
    	MessageSend(aghfp->client_task, AGHFP_AUDIO_CONNECT_IND, message);

        aghfp->audio_connection_state = aghfp_audio_accepting;
    }
    else
    {
        ConnectionSyncConnectResponse(&aghfp->task, &ind->bd_addr, FALSE, 0);
    }
}
Ejemplo n.º 2
0
/****************************************************************************
NAME    
    linkPolicyHandleRoleInd
    
DESCRIPTION
    this is a function handles notification of a role change by a remote device

RETURNS
    void
*/
void linkPolicyHandleRoleInd (CL_DM_ROLE_IND_T *ind)
{
    LP_DEBUG(("RoleInd, status=%u  role=%s\n", ind->status,  (ind->role == hci_role_master) ? "master" : "slave"));
    
    if (ind->status == hci_success)
    {
        uint16 num_sinks;
        Sink sink;
        tp_bdaddr tp_bd_addr;

        tp_bd_addr.taddr.type = TYPED_BDADDR_PUBLIC;
        tp_bd_addr.taddr.addr = ind->bd_addr;
        
        num_sinks = 1;
        sink = NULL;
        
        if (StreamSinksFromBdAddr(&num_sinks, &sink, &tp_bd_addr))
        {
            sinkA2dpSetLinkRole(sink, ind->role);
        }
    }
}