am_event_handler_audio.cc

来自「Motorola synergy audio component」· CC 代码 · 共 1,295 行 · 第 1/3 页

CC
1,295
字号
    // Do nothing on a AUD_TONE_STOP request    // send request to logic processor.    am_event_logic_processor.generate_voice(req_type);}/************** FUNCTION DEFINITIONS ******************************************//* DESCRIPTION:       Function handles an incoming aud_vt_voice_req primitive, it asks logic processor in       in application layer to turn on or off a vt voice based on request_type. (1 = on, 0 = off)   INPUTS:       generic primitive   OUTPUTS:       None   IMPORTANT NOTES:       None*/void AM_Event_Handler::handle_aud_vt_voice_req (void *msg){    AUD_VOICE_REQ * aud_voice_req = (AUD_VOICE_REQ*) msg;    TD_AUD_TONE_REQ_TYPE req_type = aud_voice_req->req_type;    if (req_type == AUD_TONE_START)    {        // if config bit is not already set for ENT MUTE, then set config bit        if (!am_event_configuration_server.read(AM_CONFIGURATION_ID_ALLOW_ENT_MUTE))        {            // set the flag that indicates to allow ENT MUTE            am_event_configuration_server.set(AM_CONFIGURATION_ID_ALLOW_ENT_MUTE, TRUE);        }         am_event_configuration_server.set (AM_CONFIGURATION_ID_INCALL , (UINT8) TRUE);    }    else    {        am_event_configuration_server.set (AM_CONFIGURATION_ID_INCALL , (UINT8) FALSE);    }    // Do nothing on a AUD_TONE_STOP request    // send request to logic processor.    am_event_logic_processor.generate_vt_voice(req_type);}/* DESCRIPTION:       Functions handles an incoming aud_tone_req. There three type of tones:       key tone, status tone and alert tone   INPUTS:       generic primitive   OUTPUTS:       None   IMPORTANT NOTES:       None*/voidAM_Event_Handler::handle_aud_tone_req(void *msg){    AUD_TONE_REQ * aud_tone_req_m = (AUD_TONE_REQ *)msg;    // extract tone type and request type from primitive    TD_AUD_TONE_UNION_T         tone              = aud_tone_req_m->tone;    TD_AUD_TONE_REQ_TYPE        req_type          = aud_tone_req_m->req_type;    TD_AUD_TONE_REQ_TONE_TYPE_T vibrate_type      = aud_tone_req_m->vibrate_type;    TD_AUD_TONE_SEQUENCE_NUMBER_T sequence        = aud_tone_req_m->sequence_number;    TD_AUD_VOLUME_SETTING_T     vol_step          = aud_tone_req_m->vol_step;    TD_AUD_TONE_UPLINK_T        uplink            = aud_tone_req_m->uplink;    TD_AUD_MEDIA_INFO_T         media_info        = aud_tone_req_m->media_info;    TD_AUD_TONE_REQ_TONE_TYPE_T tone_type_to_send = aud_tone_req_m->tone.type;    TD_AUD_TONE_REQ_TYPE        req_type_to_send  = aud_tone_req_m->req_type;    TD_AM_SAMPLING_RATE_T       sampling_rate     = aud_tone_req_m->sampling_rate;    // Sample AUDIO Logging interface.    am_send_log_data(AUD_LOG_HANDLE_AUD_TONE_REQUEST, (char *)&req_type_to_send,                      sizeof(TD_AUD_TONE_REQ_TYPE));    am_send_log_data(AUD_LOG_TONE_TYPE, (char *)&tone_type_to_send,                      sizeof(TD_AUD_TONE_REQ_TONE_TYPE_T));#if ((AUDIO_GSM == TRUE) || (AUDIO_TDMA == TRUE))    if ((tone.type ==  DL_AUDIO_TONE_TYPE_DAI_NORMAL)||        (tone.type ==  DL_AUDIO_TONE_TYPE_DAI_ANALOG_UPLINK)||        (tone.type ==  DL_AUDIO_TONE_TYPE_DAI_ANALOG_DOWNLINK)||        (tone.type ==  DL_AUDIO_TONE_TYPE_DAI_DIGITAL_UPLINK)||        (tone.type ==  DL_AUDIO_TONE_TYPE_DAI_DIGITAL_DOWNLINK)){           audio_dai_mode = tone.type;        if (tone.type != DL_AUDIO_TONE_TYPE_DAI_NORMAL)        {            am_event_logic_processor.generate_dai_command(tone.type, vol_step);        }        else        {            am_event_logic_processor.update_audio();        }    }    else if ((req_type == AUD_TONE_UPDATE)             && (audio_dai_mode != DL_AUDIO_TONE_TYPE_DAI_NORMAL))    {        am_event_logic_processor.generate_dai_command(audio_dai_mode, vol_step);    }    else#endif    am_event_logic_processor.generate_tone(tone, req_type, sequence, vol_step, vibrate_type, uplink, media_info,                                            sampling_rate);}/* DESCRIPTION:       This function handles a tone completion event. When a tone completion event comes in,       inform logic processor in the application layer.   INPUTS       The tone completion primitive.   OUTPUTS       None.   IMPORTANT NOTES       None*/ voidAM_Event_Handler::handle_audscm_tone_cmplt1(void *msg){    AUDSCM_TONE_CMPLT1_IND *audscm_tone_complete = ( AUDSCM_TONE_CMPLT1_IND *)msg;    AUD_DSP_REPLY_MSG_HEADER1 * header = (AUD_DSP_REPLY_MSG_HEADER1 *)&audscm_tone_complete->header;    UINT8 dsp_sequence_id = header->stamp;    AUD_DSP_REPLY_WORD cmplt_status = audscm_tone_complete->status;    TD_AUD_TONE_REQ_TYPE req_type   = AUD_TONE_UPDATE;    // Try to find the completed tone on the audio queue via the    // DSP sequence identifier.    Tone_Item *current = eventqueuehandler.FindbyDSPSeq(dsp_sequence_id);    TD_AUD_TONE_UNION_T tone = {audscm_tone_complete->tone};    UINT32 device_layer_sequence_id = INVALID_SEQ_NUMBER;    // If the completed tone was found on the queue, get the    // device layer sequence ID needed for processing by    // the generate_tone function.     if(current != NULL)	{	    device_layer_sequence_id = current->SequenceID;	}    // The ERR bit is on    if (cmplt_status & TONE_CMPLT_ERR_MASK)    {        ;      // Do nothing for the time being    }    /*************************************************************/    /* Only upon downlink completion is AUD_TONE_STOP request    */    /* sent, for Audio Manager never sends UL only tones to DSP  */    /*************************************************************/    if (!(cmplt_status & TONE_CMPLT_UL_DL_MASK))    {        req_type = AUD_TONE_COMPLETE;    }    // else if this is uplink complete message from DSP, &&    // this is the complete of a DTMF tone    else if (AM_Relay_Layer::IsDTMFKey(tone.fields.id))    {        am_event_logic_processor.unlock_ul_dtmf();        eventqueuehandler.TurnOffDtmfUL(current);    }    TD_AUD_MEDIA_INFO_T media_info = {NULL, INVALID_SEQ_NUMBER};    am_event_logic_processor.generate_tone(tone, req_type,                       device_layer_sequence_id,					   INVALID_VOLUME_STEP,					   DL_AUDIO_TONE_TYPE_INVALID_TONE,					   FALSE, media_info, AM_SAMPLING_RATE_08_00);}/* DESCRIPTION:       This function handles the audio error reply from the DSP.  When an       error reply is received from the DSP, log relevant data and power down       the phone.   INPUTS       The audio error reply primitive.   OUTPUTS       None.   IMPORTANT NOTES       None*/ voidAM_Event_Handler::handle_audscm_error_reply(void *msg){    AUDSCM_DSP_AUDIO_ERROR_REPLY * aud_error_reply_m = (AUDSCM_DSP_AUDIO_ERROR_REPLY *)msg;    UINT16 queue_num                                 = aud_error_reply_m->queue_num;    UINT16 bad_message_id                            = aud_error_reply_m->bad_message_id;    UINT8  bad_time_stamp                            = aud_error_reply_m->bad_time_stamp;    UINT8  bad_length                                = aud_error_reply_m->bad_length;    am_send_log_data(AUD_LOG_HANDLE_AUDSCM_ERROR_REPLY, (char *)&queue_num,                      sizeof(UINT16));    am_send_log_data(AUD_LOG_HANDLE_AUDSCM_ERROR_REPLY, (char *)&bad_message_id,                      sizeof(UINT16));    am_send_log_data(AUD_LOG_HANDLE_AUDSCM_ERROR_REPLY, (char *)&bad_time_stamp,                      sizeof(UINT8));    am_send_log_data(AUD_LOG_HANDLE_AUDSCM_ERROR_REPLY, (char *)&bad_length,                      sizeof(UINT8));    suPanic(AUDIO_PANIC_DSP_ERROR_REPLY, 0);}/* DESCRIPTION       Function to handle aud_command_req.       Transmit data, toggle hf/hs, and warm-plug's mute command are the       only commands currently used.   INPUTS       The primitive that we received.   OUTPUTS       None.   IMPORTANT NOTES       None.*/voidAM_Event_Handler::handle_aud_command_req(void *msg){    AUD_COMMAND_REQ *aud_command_req = (AUD_COMMAND_REQ *)msg;    UINT16 request          = aud_command_req->state;    switch (aud_command_req->command_type)    {        case AUD_CMD_TRANSMIT_DATA:                   //update configuration server            am_event_configuration_server.set (AM_CONFIGURATION_ID_IN_DATA_CALL, (BOOL)request);                        am_event_logic_processor.generate_data (request);            break;                    case AUD_CMD_MUTE_REQ:            handle_aud_cmd_mute_req(request);            break;                    default:            break;    }}/* DESCRIPTION:       Function to handle audio_deactivate_req, send a reset primitive to speech coder,       save all gains to eeprom before power down.  INPUTS:       none  OUTPUTS:       none  IMPORTANT NOTES:       none*/voidAM_Event_Handler::handle_audio_deactivate_req(void *msg) {    if (!(eventqueuehandler.Exists()))    {        am_deac_req_not_honored = FALSE;        am_event_logic_processor.power_down();        void * msgptr = NULL;        msgptr =  suCreateMessage((UINT32)0, (UINT32)AUDIO_DEACTIVATE_CNF_ID, SU_INVALID_HANDLE, NULL);        suSendMessage(msgptr, (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_PUD_SP, SU_WAIT_FOREVER, NULL), NULL);    }    else    {        am_event_logic_processor.stop_tones(AM_AUDIO_KEEP_PDOWN_TONE);        am_deac_req_not_honored = TRUE;    }}/* DESCRIPTION:       This function handles aud_cmd_mute_req which indicates warmplug occurs.   INPUTS:                                                 None             OUTPUTS:       None    IMPORTANT NOTES:       1. Warm plug should abort all VA/VR commands that require          user interaction.*/ voidAM_Event_Handler::handle_aud_cmd_mute_req(BOOL mute){    TD_AUD_TONE_UNION_T tone;    tone.type = DL_AUDIO_TONE_TYPE_CHARGEBATTERY_LITE;    TD_AUD_MEDIA_INFO_T media_info = {NULL, INVALID_SEQ_NUMBER};    // Set/Clear the configuration server bit which controls audio muting.    am_event_configuration_server.set(AM_CONFIGURATION_ID_MUTE, (BOOL)mute);    // generate (or disable) warm plug event to mute (or unmute) audio    am_event_logic_processor.generate_tone (tone,					    (mute ? AUD_TONE_START : AUD_TONE_STOP),					    0, INVALID_VOLUME_STEP,					    DL_AUDIO_TONE_TYPE_INVALID_TONE,					    FALSE, media_info, AM_SAMPLING_RATE_08_00);}/* DESCRIPTION:       Function to handle audio_suspend_req, sets Audio Manager to suspend state.  INPUTS:       void *msg  OUTPUTS:       none  IMPORTANT NOTES:       none*/voidAM_Event_Handler::handle_audio_suspend_req(void *msg) {    am_event_logic_processor.stop_tones(AM_AUDIO_KEEP_VOICE_TONE);    am_suspend = TRUE;    //Confirm suspend_mode to DL    void * msgptr = NULL;    msgptr =  suCreateMessage((UINT32)0, (UINT32)AUDIO_SUSPEND_CNF_ID, SU_INVALID_HANDLE, NULL);    suSendMessage(msgptr, (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_PUD_SP, SU_WAIT_FOREVER, NULL), NULL);}/* DESCRIPTION:       Function to handle audio_unsuspend_req, resets Audio Manager to the unsuspend state.  INPUTS:       void *msg  OUTPUTS:       none  IMPORTANT NOTES:       none*/voidAM_Event_Handler::handle_audio_unsuspend_req(void *msg) {    am_suspend = FALSE;    AUD_UNSUSPEND_REQ * aud_unsuspend_req = (AUD_UNSUSPEND_REQ *)msg;    if(!aud_unsuspend_req->no_cnf)    {        //Confirm unsuspend_mode to DL        void * msgptr = NULL;        msgptr =  suCreateMessage((UINT32)0, (UINT32)AUDIO_UNSUSPEND_CNF_ID,                                   SU_INVALID_HANDLE, NULL);        suSendMessage(msgptr, (SU_PORT_HANDLE)suFindName(DL_PORT_NAME_PUD_SP,                                                          SU_WAIT_FOREVER, NULL), NULL);    }}voidAM_Event_Handler::handle_aud_stop_all_tones_req(void *msg){    am_event_logic_processor.stop_tones(AM_AUDIO_KEEP_VOICE_TONE);}voidAM_Event_Handler::handle_aud_mute_req(void *msg){    AUD_MUTE_REQ * aud_mute_req = (AUD_MUTE_REQ *)msg;    switch(aud_mute_req->mute_type)    {    case DL_AUDIO_VOICE_MUTE:    case DL_AUDIO_VOICE_TX_MUTE:        am_event_logic_processor.set_tx_mute(TRUE);        break;    case DL_AUDIO_VOICE_RX_MUTE:        am_event_logic_processor.set_rx_mute(TRUE);        break;    case DL_AUDIO_VOICE_UNMUTE:    case DL_AUDIO_VOICE_TX_UNMUTE:        am_event_logic_processor.set_tx_mute(FALSE);        break;    case DL_AUDIO_VOICE_RX_UNMUTE:        am_event_logic_processor.set_rx_mute(FALSE);        break;    case DL_AUDIO_VOICE_ABSOLUTE_MUTE:        am_event_logic_processor.set_tx_mute(TRUE);        am_event_logic_processor.set_rx_mute(TRUE);        break;    case DL_AUDIO_VOICE_ABSOLUTE_UNMUTE:        am_event_logic_processor.set_tx_mute(FALSE);        am_event_logic_processor.set_rx_mute(FALSE);        break;    default:        break;    }    am_event_logic_processor.update_audio ();}voidAM_Event_Handler::handle_aud_ctia_mode_req(void *msg){    AUD_CTIA_MODE_REQ * aud_ctia_mode_req = (AUD_CTIA_MODE_REQ *)msg;    audio_ctia_mode_enabled = aud_ctia_mode_req->enabled;    audio_ctia_mode         = aud_ctia_mode_req->mode;    am_event_logic_processor.update_audio ();}void AM_Event_Handler::handle_aud_rat_change_ind(void *msg){#if (AUDIO_RAINBOW == TRUE)    AUD_RAT_CHANGE_IND * aud_rat_change_ind = (AUD_RAT_CHANGE_IND *)msg;    TD_RAT rat_type = aud_rat_change_ind->rat_type;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?