/**************************************************************************** NAME sinkPartyModeDisconnectDevice DESCRIPTION Disconnects the AG specified by the passed in a2dp link priority RETURNS successful or unable to disconnect state as true or false */ bool sinkPartyModeDisconnectDevice(a2dp_link_priority link) { PTY_DEBUG(("PTY: Disc Dev[%d] Connected[%d]\n",link ,theSink.a2dp_link_data->connected[link])); /* is a2dp connected? */ if(theSink.a2dp_link_data->connected[link]) { /* disconnect a2dp primary audio */ audioDisconnectActiveSink(); /* disconnect device bluetooth link */ A2dpSignallingDisconnectRequest(theSink.a2dp_link_data->device_id[link]); /* if hfp connected to this device then disconnect it */ if(deviceManagerIsSameDevice(link, hfp_primary_link)) HfpSlcDisconnectRequest(hfp_primary_link); else if(deviceManagerIsSameDevice(link, hfp_secondary_link)) HfpSlcDisconnectRequest(hfp_secondary_link); #ifdef ENABLE_MAPC /* Disconnect all MAPC links */ mapcDisconnectMns(); #endif #ifdef ENABLE_PBAP /* Disconnect all PBAP links */ pbapDisconnect(); #endif return TRUE; } /* didn't disconnect anything */ else return FALSE; }
/**************************************************************************** NAME linkPolicyCheckRoles DESCRIPTION this function obtains the sinks of any connection and performs a role check on them RETURNS void */ void linkPolicyCheckRoles(void) { Sink sink_pri, sink_sec, sink_a2dp_pri, sink_a2dp_sec; /* obtain any hfp link sinks */ HfpLinkGetSlcSink(hfp_primary_link, &sink_pri); HfpLinkGetSlcSink(hfp_secondary_link, &sink_sec); /* obtain sinks for any a2dp links */ sink_a2dp_pri = A2dpSignallingGetSink(theSink.a2dp_link_data->device_id[a2dp_primary]); sink_a2dp_sec = A2dpSignallingGetSink(theSink.a2dp_link_data->device_id[a2dp_secondary]); LP_DEBUG(("LP: linkPolicyCheckRoles: Hfp pri = %x, sec = %x, A2dp pri = %x, sec = %x\n",(uint16)sink_pri ,(uint16)sink_sec ,(uint16)sink_a2dp_pri ,(uint16)sink_a2dp_sec)) ; /* if primary hfp exists then check its role */ if(sink_pri) linkPolicyGetRole(&sink_pri); /* if secondary hfp connection then check its role */ if(sink_sec) linkPolicyGetRole(&sink_sec); /* if primary a2dp exists and it is not the same device as pri or sec hfp connections */ if((sink_a2dp_pri)&&(!deviceManagerIsSameDevice(a2dp_primary, hfp_primary_link))&&(!deviceManagerIsSameDevice(a2dp_primary, hfp_secondary_link))) linkPolicyGetRole(&sink_a2dp_pri); /* if secondary a2dp exists and it is not the same device as pri or sec hfp connections */ if((sink_a2dp_sec)&&(!deviceManagerIsSameDevice(a2dp_secondary, hfp_primary_link))&&(!deviceManagerIsSameDevice(a2dp_secondary, hfp_secondary_link))) linkPolicyGetRole(&sink_a2dp_sec); #ifdef ENABLE_SUBWOOFER /* check the subwoofer signalling sink if connected, this will have an impact of the role required for AG connections to prevent a scatternet scenario */ if(SwatGetSignallingSink(theSink.rundata->subwoofer.dev_id)) { Sink sink = SwatGetSignallingSink(theSink.rundata->subwoofer.dev_id); linkPolicyGetRole(&sink); } #endif }
static uint16 linkPolicyNumberPhysicalConnections (void) { uint16 connections = 0; Sink sink_pri, sink_sec, sink_a2dp_pri, sink_a2dp_sec; /* obtain any hfp link sinks */ HfpLinkGetSlcSink(hfp_primary_link, &sink_pri); HfpLinkGetSlcSink(hfp_secondary_link, &sink_sec); /* obtain sinks for any a2dp links */ sink_a2dp_pri = A2dpSignallingGetSink(theSink.a2dp_link_data->device_id[a2dp_primary]); sink_a2dp_sec = A2dpSignallingGetSink(theSink.a2dp_link_data->device_id[a2dp_secondary]); /* if primary hfp exists then check its role */ if (sink_pri) { connections++; } /* if secondary hfp connection then check its role */ if (sink_sec) { connections++; } /* if primary a2dp exists and it is not the same device as pri or sec hfp connections */ if (sink_a2dp_pri && !deviceManagerIsSameDevice(a2dp_primary, hfp_primary_link) && !deviceManagerIsSameDevice(a2dp_primary, hfp_secondary_link)) { connections++; } /* if secondary a2dp exists and it is not the same device as pri or sec hfp connections */ if (sink_a2dp_sec && !deviceManagerIsSameDevice(a2dp_secondary, hfp_primary_link) && !deviceManagerIsSameDevice(a2dp_secondary, hfp_secondary_link)) { connections++; } LP_DEBUG(("LP: Number of physical connections = %u\n", connections )); return connections; }