/**************************************************************************** NAME appCallOpenReq DESCRIPTION Request to create a call. */ static void appCallOpenReq (devInstanceTaskData *inst) { DEBUG_EVENT(("appCallOpenReq app_state:%x\n", the_app->app_state)); switch ( the_app->app_state ) { case AppStateStreaming: { if ( the_app->active_encoder!=EncoderSco && the_app->active_encoder!=EncoderWbs ) { DEBUG_EVENT((" - IGNORED, ENCODER INVALID\n")); break; } /* else fall through to AppStateConnected case */ } case AppStateIdle: { setAppState(AppStateInCall); aghfpCallCreate(inst, the_app->call_type); break; } default: { DEBUG_EVENT((" - IGNORED\n")); break; } } }
/**************************************************************************** NAME commActionCall DESCRIPTION Handles create call comm action. */ static bool commActionCall(mvdCommAction *comm_action) { devInstanceTaskData *inst = NULL; bool command_to_process = FALSE; switch (the_app->app_state) { case AppStateIdle: { /* See if a HandsFree device is connected. This assumes that a maximum of 1 can be connected. */ if ((inst = aghfpSlcGetConnectedHF()) != NULL) { /* HF is connected so create a new call */ the_app->comm_action = CommActionCall; appCallOpenReq(inst); } /* TODO - can create a connection if one doesn't exist */ else { /* No last paired device, ignore this command and check for any queued action */ command_to_process = checkPendingCommAction(comm_action); } break; } case AppStateStreaming: { if ( ((inst = aghfpSlcGetConnectedHF()) != NULL) && (the_app->active_encoder==EncoderSco || the_app->active_encoder==EncoderWbs) ) { /* Create a new call using the existing SCO/WBS audio connection */ DEBUG_EVENT(("kick Call Open\n")); the_app->comm_action = CommActionCall; appCallOpenReq(inst); } else { /* Stop streaming audio so that a call can be created */ DEBUG_EVENT(("kick Stop streaming\n")); the_app->comm_action = CommActionCall; appStreamCloseReq(); } break; } case AppStateInCall: { /* In correct state, check for any queued action */ command_to_process = checkPendingCommAction(comm_action); break; } default: { /* Command issued in wrong state, queue it */ the_app->pending_comm_action = CommActionCall; break; } } return command_to_process; }
/**************************************************************************** NAME eventHandleCancelCommAction DESCRIPTION Cancels all comm actions. */ void eventHandleCancelCommAction (void) { /* Cancel any current and queued action */ DEBUG_EVENT(("eventHandleCancelCommAction\n")); the_app->comm_action = CommActionNone; the_app->pending_comm_action = CommActionNone; }
/**************************************************************************** NAME appCallCloseReq DESCRIPTION Request to end a call. */ static void appCallCloseReq (void) { DEBUG_EVENT(("appCallCloseReq app_state:%x\n", the_app->app_state)); switch ( the_app->app_state ) { case AppStateInCall: { aghfpCallEnd(); break; } default: { DEBUG_EVENT((" - IGNORED\n")); break; } } }
/**************************************************************************** NAME a2dpStreamSetAudioStreamingState DESCRIPTION Sets a new audio streaming state. */ void a2dpStreamSetAudioStreamingState (mvdStreamingState streaming_state) { DEBUG_EVENT(("a2dpStreamSetAudioStreamingState(%u)\n", (uint16)streaming_state)); /* Set new streaming state and always cancel any outstanding timer messages */ the_app->audio_streaming_state = streaming_state; MessageCancelAll(&the_app->task, APP_AUDIO_STREAMING_TIMER); }
void ABCC_LinkCheckSendMessage( void ) { BOOL fSendMsg = FALSE; ABP_MsgType* psWriteMessage = NULL; ABCC_SYS_UseCritical(); /* ** Check if any messages are queued. ** If the queue index > 0 then there are messages in the qeueue. ** Response messages are prioritised before command messages. */ ABCC_SYS_EnterCritical(); if ( link_sRespQueue.bNumInQueue > 0 ) { if( pnABCC_DrvISReadyForWriteMessage() ) { psWriteMessage = link_DeQueue( &link_sRespQueue ); fSendMsg = TRUE; DEBUG_EVENT(("RESP send msg")); } } else if ( link_sCmdQueue.bNumInQueue > 0 ) { if( pnABCC_DrvISReadyForCmd() ) { psWriteMessage = link_DeQueue( &link_sCmdQueue ); fSendMsg = TRUE; DEBUG_EVENT(("CMD send msg")); } else { DEBUG_EVENT(("Denied CMD send msg")); } } if ( fSendMsg ) { if ( pnABCC_DrvWriteMessage( psWriteMessage ) ) { link_CheckNotification( psWriteMessage ); ABCC_LinkFree( &psWriteMessage ); } } ABCC_SYS_ExitCritical(); }
/**************************************************************************** NAME appStreamOpenReq DESCRIPTION Request to stream over A2DP or (e)SCO connection. */ static void appStreamOpenReq (void) { devInstanceTaskData *inst; DEBUG_EVENT(("appStreamOpenReq AppState(%s), Active encoder:%x\n",s_app_states[the_app->app_state], the_app->active_encoder)); switch ( the_app->app_state ) { case AppStateIdle: { if ( the_app->active_encoder == EncoderNone ) { /* Not already streaming audio */ if(a2dpSlcIsMediaOpen()) { a2dpStreamStartA2dp(); } else if ((inst = aghfpSlcGetConnectedHF()) != NULL) { setAppState(AppStateStreaming); aghfpSlcAudioOpen(inst); } else { /* No suitable profile to use for audio streaming */ } } else { /* There's an active encoder so the app state must be updated to streaming */ setAppState(AppStateStreaming); /* Move any A2DP devices that are in the open state to streaming state */ a2dpStreamStartA2dp(); } break; } default: { DEBUG_EVENT((" - IGNORED\n")); break; } } }
/**************************************************************************** NAME appDisconnectReq DESCRIPTION Disconnects all active connections. */ static void appDisconnectReq (void) { DEBUG_EVENT(("appDisconnectReq AppState(%s)\n",s_app_states[the_app->app_state])); switch ( the_app->app_state ) { case AppStateIdle: { the_app->disconnect_requested = TRUE; avrcpSlcDisconnectAll(); a2dpSlcDisconnectAll(); aghfpSlcDisconnectAll(); break; } default: { DEBUG_EVENT((" - IGNORED\n")); break; } } }
/**************************************************************************** NAME eventHandleInstanceMessage DESCRIPTION Handles the application messages associated with a device instance. */ void eventHandleInstanceMessage(devInstanceTaskData *inst, MessageId id, Message message) { switch (id) { case APP_REFRESH_ENCRYPTION_REQ: { DEBUG_EVENT(("APP_REFRESH_ENCRYPTION_REQ inst:[0x%x]\n", (uint16)inst)); handleAppRefreshEncryptionReq(inst); break; } case APP_PROFILE_CONNECT_TIMER: { DEBUG_EVENT(("APP_PROFILE_CONNECT_TIMER inst:[0x%x]\n", (uint16)inst)); /* The device has become unresponsive. Finish the connection attempt. */ profileSlcCancelConnectionAttempt(inst); break; } case APP_INTERNAL_DESTROY_REQ: { DEBUG_EVENT(("APP_INTERNAL_DESTROY_REQ inst:[0x%x]\n", (uint16)inst)); devInstanceDestroy(inst); return; } case APP_INTERNAL_CONNECT_MEDIA_CHANNEL_REQ: { DEBUG_EVENT(("APP_INTERNAL_CONNECT_MEDIA_CHANNEL_REQ inst:[0x%x]\n", (uint16)inst)); a2dpSlcConnect(inst); return; } case APP_MEDIA_CHANNEL_REOPEN_REQ: { DEBUG_EVENT(("APP_MEDIA_CHANNEL_REOPEN_REQ inst:[0x%x]\n", (uint16)inst)); a2dpSlcReOpen(inst); return; } case APP_CONNECT_TIMER: { DEBUG_EVENT(("APP_CONNECT_TIMER\n")); inst->connect_timer_expired = TRUE; /* the_app->connect_bdaddr = inst->bd_addr; kickCommAction(CommActionConnect);*/ return; } case APP_CONNECT_CFM: { DEBUG_EVENT(("APP_CONNECT_CFM\n")); profileSlcConnectComplete(inst, ((APP_CONNECT_CFM_T *)message)->success); break; } default: { break; } } }
/**************************************************************************** NAME handleAppPowerOnReq DESCRIPTION Handles the application power on request message. */ static void handleAppPowerOnReq(void) { if(!(the_app->audioAdaptorPoweredOn) ) { DEBUG_EVENT(("Powering on...\n")); /* Cancel the event message if there was one so it doesn't power off */ MessageCancelAll ( &the_app->task, APP_LIMBO_TIMEOUT ) ; the_app->audioAdaptorPoweredOn = TRUE; the_app->PowerOffIsEnabled = TRUE; /* Power on the Analogue Dongle when APP_POWERON_REQ Message is received */ /* profileSlcStartConnectionProcess();*/ } }
/**************************************************************************** NAME checkPendingCommAction DESCRIPTION Returns the pending comm action in comm_action and resets the current and pending comm actions. */ static bool checkPendingCommAction (mvdCommAction *comm_action) { the_app->comm_action = CommActionNone; if ( the_app->pending_comm_action!=CommActionNone ) { DEBUG_EVENT(("checkPendingCommAction [%s]\n",s_comm_action_names[the_app->pending_comm_action])); *comm_action = the_app->pending_comm_action; the_app->pending_comm_action = CommActionNone; return TRUE; } return FALSE; }
/**************************************************************************** NAME appStreamCloseReq DESCRIPTION Request to close any open streams over A2DP or (e)SCO connection. */ static void appStreamCloseReq (void) { DEBUG_EVENT(("appStreamCloseReq AppState(%s), Active encoder:%x\n",s_app_states[the_app->app_state], the_app->active_encoder)); switch ( the_app->app_state ) { case AppStateStreaming: { switch ( the_app->active_encoder ) { case EncoderNone: { MessageSend(&the_app->task, APP_STREAM_CLOSE_COMPLETE, 0); break; } case EncoderAv: case EncoderAnalog: { a2dpStreamCeaseA2dpStreaming(); break; } case EncoderSco: case EncoderWbs: { aghfpSlcAudioClose(); break; } } break; } default: { DEBUG_EVENT((" - IGNORED\n")); break; } } }
void get_debug_event() { PCONTEXT ctx; debug_event = DEBUG_EVENT(); ctn_status = DBG_CONTINUE; if (WaitForDebugEvent(&debug_event, INFINITE)) { h_thread = open_thread(debug_event.dwThreadId); ctx = get_thread_context(h_thread, NULL); std::cout << "[E] Event Code : " << debug_event.dwDebugEventCode << " Thread ID : " << debug_event.dwThreadId << std::endl; if (debug_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT) { exception = debug_event.u.Exception.ExceptionRecord.ExceptionCode; exception_address = debug_event.u.Exception.ExceptionRecord.ExceptionAddress; switch (exception) { case EXCEPTION_ACCESS_VIOLATION: std::cout << "[EXCEPTION] ACCESS VIOLATION." << std::endl; break; case EXCEPTION_BREAKPOINT: ctn_status = exception_handler_breakpoint(); break; case EXCEPTION_GUARD_PAGE: std::cout << "[EXCEPTION] Guard Page Access Detected." << std::endl; break; case EXCEPTION_SINGLE_STEP: std::cout << "[EXCEPTION] Single Stepping." << std::endl; break; default: break; } ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, ctn_status); } } ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, ctn_status); }
//------------------------------------------------------------------------------ // Name: DebugEvent() // Desc: constructor //------------------------------------------------------------------------------ DebugEvent::DebugEvent() : event(DEBUG_EVENT()){ }
//------------------------------------------------------------------------------ // Name: // Desc: //------------------------------------------------------------------------------ PlatformEvent::PlatformEvent() : event(DEBUG_EVENT()) { }
/**************************************************************************** NAME unexpectedAppMessage DESCRIPTION For debug purposes to track unhandled application messages. */ static void unexpectedAppMessage(MessageId id, mvdAppState state) { DEBUG_EVENT(("Unexpected application specific message 0x%X in state %u\n", (uint16)id, (uint16)state)); }
/**************************************************************************** NAME kickCommAction DESCRIPTION Used to kick off a comm action eg. connect/disconnect. */ void kickCommAction (mvdCommAction comm_action) { bool command_to_process; do { DEBUG_EVENT(("kickCommAction(%s) last=%s\n",s_comm_action_names[comm_action],s_comm_action_names[the_app->comm_action])); DEBUG_EVENT(("AppState(%s)\n",s_app_states[the_app->app_state])); command_to_process = FALSE; switch (comm_action) { case CommActionNone: { commActionNone(); break; } case CommActionCall: { command_to_process = commActionCall(&comm_action); break; } case CommActionEndCall: { command_to_process = commActionEndCall(&comm_action); break; } case CommActionStream: { command_to_process = commActionStream(&comm_action); break; } case CommActionEndStream: { command_to_process = commActionEndStream(&comm_action); break; } case CommActionConnect: { command_to_process = commActionConnect(&comm_action); break; } case CommActionDisconnect: { command_to_process = commActionDisconnect(&comm_action); break; } case CommActionInquire: { command_to_process = commActionInquire(&comm_action); break; } case CommActionDiscover: { command_to_process = commActionDiscover(&comm_action); break; } case CommActionDiscoverWhileConnected: { command_to_process = commActionDiscoverWhileConnected(&comm_action); break; } default: { /* Should never get here */ break; } } } while (command_to_process); }
/**************************************************************************** NAME eventHandleAppMessage DESCRIPTION Handles the application messages. */ void eventHandleAppMessage(MessageId id, Message message) { switch(id) { case APP_INIT: { DEBUG_EVENT(("APP_INIT\n")); handleAppInit(); break; } case APP_INIT_CFM: { DEBUG_EVENT(("APP_INIT_CFM\n")); handleAppInitCfm(); break; } case APP_POWERON_REQ: { DEBUG_EVENT(("APP_POWERON_REQ\n")); handleAppPowerOnReq(); break; } case APP_POWEROFF_REQ: { DEBUG_EVENT(("APP_POWEROFF_REQ\n")); break; } case APP_LIMBO_TIMEOUT: { DEBUG_EVENT(("APP_LIMBO_TIMEOUT\n")); break; } case APP_RESET_PDL_REQ: { DEBUG_EVENT(("APP_RESET_PDL_REQ\n")); handleAppResetPdlReq(); break; } case APP_CANCEL_LED_INDICATION: { DEBUG_EVENT(("APP_CANCEL_LED_INDICATION\n")); break; } case APP_KICK_COMM_ACTION_REQ: { DEBUG_EVENT(("APP_KICK_COMM_ACTION_REQ\n")); kickCommAction(((APP_KICK_COMM_ACTION_REQ_T*)message)->comm_action); break; } case APP_DEVICE_CONNECT_REQ: { DEBUG_EVENT(("APP_DEVICE_CONNECT_REQ\n")); handleAppDeviceConnectReq(((APP_DEVICE_CONNECT_REQ_T *)message)->disconnect_current); break; } case APP_DEVICE_DISCOVER_REQ: { DEBUG_EVENT(("APP_DEVICE_DISCOVER_REQ\n")); handleAppDeviceDiscoverReq(((APP_DEVICE_DISCOVER_REQ_T *)message)->disconnect_current); break; } case APP_ENTER_DFU_MODE: { DEBUG_EVENT(("APP_ENTER_DFU_MODE\n")); handleAppEnterDfuMode(); break; } case APP_VOIP_CALL_INCOMING: { /* if ( !the_app->voip_call_active )*/ { DEBUG_EVENT(("APP_VOIP_CALL_INCOMING\n")); handleAppVoipCallIncoming(); } break; } case APP_VOIP_CALL_OUTGOING: { if ( !the_app->voip_call_active ) { DEBUG_EVENT(("APP_VOIP_CALL_OUTGOING\n")); handleAppVoipCallOutgoing(); MessageSendLater(&the_app->task,APP_VOIP_CALL_ACTIVE,0,500); } break; } case APP_VOIP_CALL_CANCEL: { if ( !the_app->voip_call_active ) { DEBUG_EVENT(("APP_VOIP_CALL_CANCEL\n")); handleAppVoipCallCancel(); } break; } case APP_VOIP_CALL_ACTIVE: { if ( !the_app->voip_call_active ) { DEBUG_EVENT(("APP_VOIP_CALL_ACTIVE\n")); handleAppVoipCallActive(); } break; } case APP_VOIP_CALL_INACTIVE: { if ( the_app->voip_call_active || (the_app->app_state == AppStateInCall) ) { DEBUG_EVENT(("APP_VOIP_CALL_INACTIVE\n")); handleAppVoipCallInactive(); } break; } case APP_AUDIO_STREAMING_ACTIVE: { /* if ( the_app->audio_streaming_state != StreamingActive )*/ { DEBUG_EVENT(("APP_AUDIO_STREAMING_ACTIVE\n")); handleAppAudioStreamingActive(); } break; } case APP_AUDIO_STREAMING_INACTIVE: { if (the_app->audio_streaming_state == StreamingActive) { DEBUG_EVENT(("APP_AUDIO_STREAMING_INACTIVE\n")); handleAppAudioStreamingInactive(); } break; } case APP_AUDIO_STREAMING_TIMER: { if (the_app->audio_streaming_state == StreamingPending ) { DEBUG_EVENT(("APP_AUDIO_STREAMING_TIMER\n")); handleAppAudioStreamingTimer(); } break; } case APP_A2DP_MEDIA_STREAM_HOLDOFF: { DEBUG_EVENT(("APP_A2DP_MEDIA_STREAM_HOLDOFF\n")); handleAppA2dpMediaStreamHoldoff(); break; } case APP_INQUIRY_TIMER: { DEBUG_EVENT(("APP_INQUIRY_TIMER\n")); /* Delay time-out until we fail to connect to current remote device */ the_app->app_inquiry_timer_expired = TRUE; break; } case APP_RECONNECT_TIMER: { DEBUG_EVENT(("APP_RECONNECT_TIMER\n")); the_app->app_reconnect_timer_expired = TRUE; break; } case APP_HID_SEQUENCE: { DEBUG_EVENT(("APP_HID_SEQUENCE\n")); break; } case APP_STREAM_CLOSE_COMPLETE: { DEBUG_EVENT(("APP_STREAM_CLOSE_COMPLETE\n")); streamManagerCloseComplete(); break; } case APP_CONNECT_A2DP_AUDIO: { DEBUG_EVENT(("APP_CONNECT_A2DP_AUDIO\n")); a2dpStreamConnectA2dpAudio(((APP_CONNECT_A2DP_AUDIO_T *)message)->media_sink); break; } case APP_PROCESS_INQUIRE_RESULT: { DEBUG_EVENT(("APP_PROCESS_INQUIRE_RESULT\n")); scanProcessNextInquireResult(); break; } case APP_MSG_TIMEOUT: the_app->waiting_msg = FALSE; MessageCancelAll(&the_app->task,APP_MSG_TIMEOUT); break; default: { DEBUG_EVENT(("Unhandled APP message 0x%X\n", (uint16)id)); break; } } }