/**************************************************************************** NAME audioSwapMediaChannel DESCRIPTION attempt to swap between media channels if two channels exist and one of them is currentyl being routed to the speaker. RETURNS successful or not status */ bool audioSwapMediaChannel(void) { Sink a2dpSinkPri, a2dpSinkSec; a2dp_stream_state a2dpStatePri, a2dpStateSec; /* get the status of the a2dp links */ getA2dpStreamData(a2dp_primary, &a2dpSinkPri, &a2dpStatePri); getA2dpStreamData(a2dp_secondary, &a2dpSinkSec, &a2dpStateSec); /* check whether a2dp pri is currently being routed and a2dp sec is available */ if((theSink.routed_audio == a2dpSinkPri)&&(a2dpSinkSec)&&(a2dpStateSec == a2dp_stream_streaming)) { /* swap to a2dp secondary */ AudioDisconnect(); A2dpRouteAudio(a2dp_secondary, a2dpSinkSec); return TRUE; } /* check whether a2dp sec is currently being routed and swap to a2dp pri */ else if((theSink.routed_audio == a2dpSinkSec)&&(a2dpSinkPri)&&(a2dpStatePri == a2dp_stream_streaming)) { AudioDisconnect(); A2dpRouteAudio(a2dp_primary, a2dpSinkPri); return TRUE; } /* not possible to swap media channels */ return FALSE; }
/**************************************************************************** NAME audio_aghfp_disconnect - Disconnect AGHFP audio */ void audio_aghfp_disconnect(void) { if (theSource->audio_data.audio_routed == AUDIO_ROUTED_AGHFP) { theSource->audio_data.audio_routed = AUDIO_ROUTED_NONE; /* unroute audio */ AudioDisconnect(); } }
/**************************************************************************** NAME usbAudioDisconnect DESCRIPTION Disconnect USB audio stream RETURNS void */ void usbAudioDisconnect(void) { if(usbAudioSinkMatch(theSink.routed_audio)) { USB_DEBUG(("USB: Disconnect 0x%X\n", (uint16)theSink.routed_audio)); AudioDisconnect(); theSink.routed_audio = 0; /* If speaker is in use then pause */ if(theSink.usb.spkr_active) UsbDeviceClassSendEvent(USB_DEVICE_CLASS_EVENT_HID_CONSUMER_TRANSPORT_PAUSE); } }
/**************************************************************************** NAME audio_a2dp_disconnect_all - Disconnect all A2DP audio */ void audio_a2dp_disconnect_all(void) { uint16 index = 0; if (theSource->audio_data.audio_routed == AUDIO_ROUTED_A2DP) { theSource->audio_data.audio_routed = AUDIO_ROUTED_NONE; for (index = 0; index < CSR_A2DP_ENCODER_PLUGIN_MAX_A2DP_SINKS; index++) { theSource->audio_data.audio_a2dp_connect_params.a2dp_sink[index] = 0; } AudioDisconnect(); } }
void hfpHandlerAudioDisconnectInd( const HFP_AUDIO_DISCONNECT_IND_T *ind ) { if (theHeadset.dsp_process == dsp_process_sco) { AudioDisconnect() ; theHeadset.dsp_process = dsp_process_none; } /* Try to resume A2DP streaming if not outgoing or incoming call */ if ((stateManagerGetHfpState() != headsetIncomingCallEstablish) && (stateManagerGetHfpState() != headsetOutgoingCallEstablish)) { if ((stateManagerGetHfpState() == headsetActiveCall) && IsA2dpSourceAnAg()) { /* Do nothing with A2DP_AG as the music can't start while call active */ } else { streamControlResumeA2dpStreaming(0); } } MessageSend ( &theHeadset.task , EventSCOLinkClose , 0 ) ; theHeadset.HSPCallAnswered = FALSE; /* If this is a headset instance, end the call */ if ( theHeadset.profile_connected == hfp_headset_profile ) { if(stateManagerIsHfpConnected()) { stateManagerEnterHfpConnectedState() ; } } /* If we are muted - then un mute at disconnection */ if (theHeadset.gMuted ) { MessageSend(&theHeadset.task , EventMuteOff , 0) ; } /* Update Link Policy as SCO has disconnected. */ linkPolicySCOdisconnect(); }
/**************************************************************************** NAME StopHearingDSP DESCRIPTION stops Hearing plugin and DSP and disconnects all relevant audio. RETURNS void */ void StopHearingDSP(void) { LMEndMessage_t * lLMEndMessage = PanicUnlessMalloc(sizeof(LMEndMessage_t)); lLMEndMessage->Event = EventUsrSubwooferDisconnect; lLMEndMessage->PatternCompleted = TRUE; if (theSink.HearPhones_conf->Hearing.ActiveHearing) { AUD_DEBUG(("AUD: stop Hearing Mode\n")) ; SetAudioBusy(NULL); AudioDisconnect(); theSink.HearPhones_conf->Hearing.ActiveHearing = 0; MessageSend(&theSink.task, EventSysCancelLedIndication, 0);/*EventSysCancelLedIndication*/ MessageSend(&theSink.task, EventSysLEDEventComplete, lLMEndMessage);/*EventSysCancelLedIndication*/ #ifndef DSP_MY_FIRST_KALIMBA TonesPlayTone ( 50, TRUE , TRUE); #endif } }
/**************************************************************************** NAME sinkFmRxAudioDisconnect DESCRIPTION Disconnects the FM audio via the audio library/FM audio plugin RETURNS nothing */ void sinkFmRxAudioDisconnect(void) { FM_DEBUG(("sinkFmRxAudioDisconnect \n")); /* ensure FM is on and FM audio currently being routed to speaker */ if ((theSink.conf2->sink_fm_data.fmRxOn) && sinkFmAudioSinkMatch(theSink.routed_audio)) { FM_DEBUG(("FM audio disconnected \n")); /* reset routed audio */ theSink.routed_audio = 0; /* disconnect FM audio via audio library */ AudioDisconnect(); /* Update limbo state */ if (stateManagerGetState() == deviceLimbo ) stateManagerUpdateLimboState(); } }
/**************************************************************************** NAME a2dpStreamCeaseA2dpStreaming DESCRIPTION To stop A2dp streaming for any media channels currently streaming. */ void a2dpStreamCeaseA2dpStreaming(void) { devInstanceTaskData *inst; uint16 i; DEBUG_A2DP(("a2dpStreamCeaseA2dpStreaming\n")); for (i = 0; i < MAX_NUM_DEV_CONNECTIONS; i++) { inst = the_app->dev_inst[i]; if (inst != NULL) { if (inst->a2dp != NULL) { switch (getA2dpState(inst)) { case A2dpStateStreaming: { setA2dpState(inst, A2dpStateSuspending); A2dpSuspend(inst->a2dp); break; } default: { break; } } } } } /* Stop the audio processing if currently handling A2DP */ if (the_app->active_encoder == EncoderAv) { AudioDisconnect(); the_app->active_encoder = EncoderNone; a2dpStreamSetDspIdle(); DEBUG_A2DP(("AudioDisconnect\n")); } }
/**************************************************************************** NAME disconnectAudio DESCRIPTION Disconnects the specified SCO/eSCO channel from the DSP. */ static void disconnectAudio (devInstanceTaskData *inst) { DEBUG_AGHFP((" disconnectAudio(0x%X)\n", (uint16)inst->audio_sink)); if (inst->audio_sink) { SendEvent(EVT_AUDIO_DISCONNECT_IND,0); if (the_app->active_encoder == EncoderSco) { ledSetProfile(LedTypeSCO,FALSE); AudioDisconnect(); #ifdef KAL_MSGxx /* Switch the DSP to IDLE mode */ PanicFalse(KalimbaSendMessage(KALIMBA_ENCODER_SELECT, EncoderNone, 0, 0, 0)); #endif the_app->active_encoder = EncoderNone; } inst->audio_sink = 0; } }
/* Dial the first entry in the phonebook */ void pbapDialPhoneBook( uint8 phonebook ) { if(theHeadset.pbap_dial_state != pbapc_dialling) { if (!stateManagerIsConnected() ) { #ifdef ENABLE_AVRCP headsetAvrcpCheckManualConnectReset(NULL); #endif PBAP_DEBUG(("Pbap dial, Connect the HFP profile first\n")); MessageSend ( &theHeadset.task , EventEstablishSLC , 0 ) ; switch(phonebook) { case pbap_ich: headsetQueueEvent( EventPbapDialIch ) ; break; case pbap_mch: headsetQueueEvent( EventPbapDialMch ) ; break; default: break; } } else { #ifdef ActiveRubiASR #if 0 if(strcmp(TTS_text , "")) { PBAP_DEBUG(("Pbap : Rubi > UnloadRubiEngine***\n")); TTSTerminate(); AudioDisconnect(); /* clear sco_sink value to indicate no routed audio */ theHeadset.sco_sink = 0; UnloadRubidiumEngine(); memset(TTS_text, 0, sizeof(TTS_text)); } #endif if(theHeadset.TTS_ASR_Playing) { PBAP_DEBUG(("Pbap : Rubi > UnloadRubiEngine***\n")); TTSTerminate(); AudioDisconnect(); /* clear sco_sink value to indicate no routed audio */ theHeadset.sco_sink = 0; UnloadRubidiumEngine(); theHeadset.TTS_ASR_Playing = false; } #endif pbapDial(phonebook); } theHeadset.pbap_dial_state = pbapc_dialling; } }