static void ConnectAudioToI2s ( ) { le_result_t res; // Redirect audio to the I2S interface. FeOutRef = le_audio_OpenI2sTx(LE_AUDIO_I2S_STEREO); LE_ERROR_IF((FeOutRef==NULL), "OpenI2sTx returns NULL!"); FeInRef = le_audio_OpenI2sRx(LE_AUDIO_I2S_STEREO); LE_ERROR_IF((FeInRef==NULL), "OpenI2sRx returns NULL!"); LE_INFO("Open I2s: FeInRef.%p FeOutRef.%p", FeInRef, FeOutRef); AudioInputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioInputConnectorRef==NULL), "AudioInputConnectorRef is NULL!"); AudioOutputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioOutputConnectorRef==NULL), "AudioOutputConnectorRef is NULL!"); if (MdmRxAudioRef && MdmTxAudioRef && FeOutRef && FeInRef && AudioInputConnectorRef && AudioOutputConnectorRef) { res = le_audio_Connect(AudioInputConnectorRef, FeInRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect I2S RX on Input connector!"); res = le_audio_Connect(AudioInputConnectorRef, MdmTxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmTx on Input connector!"); res = le_audio_Connect(AudioOutputConnectorRef, FeOutRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect I2S TX on Output connector!"); res = le_audio_Connect(AudioOutputConnectorRef, MdmRxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmRx on Output connector!"); } LE_INFO("Open I2s: FeInRef.%p FeOutRef.%p", FeInRef, FeOutRef); }
//-------------------------------------------------------------------------------------------------- static void PlayFile ( const char* audioFilePathPtr, bool isInLoop ) { char filePathPtr[100]={0}; IsInLoop = isInLoop; if (AudioFileFormat == LE_AUDIO_AMR) { snprintf(filePathPtr, 100, "%s.amr", audioFilePathPtr); } else { snprintf(filePathPtr, 100, "%s.wav", audioFilePathPtr); } if ((AudioFileFd=open(filePathPtr, O_RDONLY)) == -1) { LE_ERROR("Open file %s failure: errno.%d (%s)", filePathPtr, errno, strerror(errno)); exit(0); } else { LE_INFO("Play file %s %s with AudioFileFd.%d", ((IsInLoop) ? "IN LOOP" : "ONCE"), filePathPtr, AudioFileFd); } LE_ERROR_IF((le_audio_PlayFile(PlayerRef, AudioFileFd) != LE_OK), "Cannot play file"); }
//-------------------------------------------------------------------------------------------------- static void HangUpTimerHandler ( le_timer_Ref_t timerRef ) { LE_INFO("Hanging up all calls!"); LE_ERROR_IF(le_mcc_HangUpAll() != LE_OK, "Could not hangup."); }
static le_result_t OpenAudio ( le_voicecall_CallRef_t reference ) { MdmRxAudioRef = le_voicecall_GetRxAudioStream(reference); LE_ERROR_IF((MdmRxAudioRef==NULL), "le_voicecall_GetRxAudioStream returns NULL!"); MdmTxAudioRef = le_voicecall_GetTxAudioStream(reference); LE_ERROR_IF((MdmTxAudioRef==NULL), "le_voicecall_GetRxAudioStream returns NULL!"); LE_DEBUG("OpenAudio MdmRxAudioRef %p, MdmTxAudioRef %p", MdmRxAudioRef, MdmTxAudioRef); LE_INFO("Connect I2S"); ConnectAudioToI2s(); return LE_OK; }
//-------------------------------------------------------------------------------------------------- static void ConnectAudioToFileLocalPlay ( void ) { le_result_t res; if ((AudioFileFd=open(AudioFileRecPath, O_RDWR)) == -1) { LE_ERROR("Open file %s failure: errno.%d (%s)", AudioFileRecPath, errno, strerror(errno)); } else { LE_INFO("Open file %s with AudioFileFd.%d", AudioFileRecPath, AudioFileFd); } // Play local on output connector. FileAudioRef = le_audio_OpenPlayer(); LE_ERROR_IF((FileAudioRef==NULL), "OpenFilePlayback returns NULL!"); MediaHandlerRef = le_audio_AddMediaHandler(FileAudioRef, MyMediaEventHandler, NULL); LE_ERROR_IF((MediaHandlerRef==NULL), "AddMediaHandler returns NULL!"); if (FileAudioRef && AudioOutputConnectorRef) { res = le_audio_Connect(AudioOutputConnectorRef, FileAudioRef); if(res!=LE_OK) { LE_ERROR("Failed to connect FilePlayback on output connector!"); return; } LE_INFO("FilePlayback is now connected."); res = le_audio_PlayFile(FileAudioRef, AudioFileFd); if(res != LE_OK) { LE_ERROR("Failed to play the file!"); } else { LE_INFO("File is now playing"); } } }
//-------------------------------------------------------------------------------------------------- static void ConnectAudioToAnalog ( void ) { le_result_t res; MdmRxAudioRef = le_audio_OpenModemVoiceRx(); LE_ERROR_IF((MdmRxAudioRef==NULL), "GetRxAudioStream returns NULL!"); MdmTxAudioRef = le_audio_OpenModemVoiceTx(); LE_ERROR_IF((MdmTxAudioRef==NULL), "GetTxAudioStream returns NULL!"); // Redirect audio to the in-built Microphone and Speaker. FeOutRef = le_audio_OpenSpeaker(); LE_ERROR_IF((FeOutRef==NULL), "OpenSpeaker returns NULL!"); FeInRef = le_audio_OpenMic(); LE_ERROR_IF((FeInRef==NULL), "OpenMic returns NULL!"); LE_INFO("Open Analog: FeInRef.%p FeOutRef.%p", FeInRef, FeOutRef); AudioInputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioInputConnectorRef==NULL), "AudioInputConnectorRef is NULL!"); AudioOutputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioOutputConnectorRef==NULL), "AudioOutputConnectorRef is NULL!"); if (MdmRxAudioRef && MdmTxAudioRef && FeOutRef && FeInRef && AudioInputConnectorRef && AudioOutputConnectorRef) { res = le_audio_Connect(AudioInputConnectorRef, FeInRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect Mic on Input connector!"); res = le_audio_Connect(AudioInputConnectorRef, MdmTxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmTx on Input connector!"); res = le_audio_Connect(AudioOutputConnectorRef, FeOutRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect Speaker on Output connector!"); res = le_audio_Connect(AudioOutputConnectorRef, MdmRxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmRx on Output connector!"); } LE_INFO("Open Analog: FeInRef.%p FeOutRef.%p", FeInRef, FeOutRef); }
//-------------------------------------------------------------------------------------------------- static void TestSimToolkitHandler ( le_sim_Id_t simId, le_sim_StkEvent_t stkEvent, void* contextPtr ) { switch(stkEvent) { case LE_SIM_OPEN_CHANNEL: LE_INFO("-TEST- OPEN_CHANNEL SIM Toolkit event for SIM card.%d", simId); break; case LE_SIM_REFRESH: LE_INFO("-TEST- REFRESH SIM Toolkit event for SIM card.%d", simId); break; case LE_SIM_STK_EVENT_MAX: default: LE_INFO("-TEST- Unknown SIM Toolkit event %d for SIM card.%d", stkEvent, simId); break; } if( strncmp(AcceptCmdArg, "accept", strlen("accept")) == 0 ) { LE_INFO("-TEST- Accept SIM Toolkit command"); LE_ERROR_IF((le_sim_AcceptSimToolkitCommand(simId) != LE_OK), "Accept SIM Toolkit failure!"); } else if( strncmp(AcceptCmdArg, "reject", strlen("reject")) == 0 ) { LE_INFO("-TEST- Reject SIM Toolkit command"); LE_ERROR_IF((le_sim_RejectSimToolkitCommand(simId) != LE_OK), "Reject SIM Toolkit failure!"); } else if( strncmp(AcceptCmdArg, "none", strlen("none")) == 0 ) { LE_INFO("-TEST- Don't answer to SIM Toolkit command"); } }
//-------------------------------------------------------------------------------------------------- static void ConnectAudioToFileRec ( void ) { le_result_t res; if ((AudioFileFd=open(AudioFileRecPath, O_RDWR | O_CREAT | O_TRUNC)) == -1) { LE_ERROR("Open file %s failure: errno.%d (%s)", AudioFileRecPath, errno, strerror(errno)); } else { LE_INFO("Open file %s with AudioFileFd.%d", AudioFileRecPath, AudioFileFd); } // Capture Remote on output connector. FileAudioRef = le_audio_OpenRecorder(); LE_ERROR_IF((FileAudioRef==NULL), "OpenFileRecording returns NULL!"); if (FileAudioRef && AudioOutputConnectorRef) { res = le_audio_Connect(AudioOutputConnectorRef, FileAudioRef); if(res!=LE_OK) { LE_ERROR("Failed to connect FileRecording on output connector!"); return; } res = le_audio_Connect(AudioInputConnectorRef, FileAudioRef); if(res!=LE_OK) { LE_ERROR("Failed to connect FileRecording on input connector!"); return; } LE_INFO("Recorder is now connected."); res = le_audio_RecordFile(FileAudioRef, AudioFileFd); if(res!=LE_OK) { LE_ERROR("Failed to record the file"); } else { LE_INFO("File is now recording."); } } }
//-------------------------------------------------------------------------------------------------- static void MyMediaEventHandler ( le_audio_StreamRef_t streamRef, le_audio_MediaEvent_t event, void* contextPtr ) { switch(event) { case LE_AUDIO_MEDIA_NO_MORE_SAMPLES: LE_INFO("Media event is LE_AUDIO_MEDIA_NO_MORE_SAMPLES."); break; case LE_AUDIO_MEDIA_ENDED: LE_INFO("Media event is LE_AUDIO_MEDIA_ENDED."); if (IsInLoop) { // Start playing audio file in loop LE_INFO("Play in loop..."); LE_ERROR_IF((le_audio_PlayFile(streamRef, LE_AUDIO_NO_FD) != LE_OK), "Cannot play file"); } if(IsVoicePromptStart) { PlayFile(DIALING, true); IsVoicePromptStart = false; IsDialing = true; } else if(IsDialing) { // Initiate the call LE_INFO("Start call"); le_mcc_Start(TestCallRef); IsDialing = false; } break; case LE_AUDIO_MEDIA_ERROR: LE_INFO("Media event is LE_AUDIO_MEDIA_ERROR."); break; default: LE_INFO("Media event is %d.", event); break; } }
static void CallbackTestHandler ( le_sms_MsgRef_t msgRef, le_sms_Status_t status, void* contextPtr ) { LE_INFO("Message %p, status %d, ctx %p", msgRef, status, contextPtr); le_sms_Delete(msgRef); LE_ERROR_IF(status != LE_SMS_SENT, "Test FAILED") NbSmsTx--; LE_INFO("Number of callback event remaining %d", NbSmsTx); if (NbSmsTx == 0) { sem_post(&SmsTxSynchronization); } }
//-------------------------------------------------------------------------------------------------- void le_mrc_Init ( void ) { le_result_t result=LE_OK; pa_mrc_NetworkRegSetting_t setting; // Create an event Id for new Network Registration State notification NewNetRegStateId = le_event_CreateIdWithRefCounting("NewNetRegState"); ScanInformationListPool = le_mem_CreatePool("ScanInformationListPool", sizeof(le_mrc_ScanInformationList_t)); ScanInformationSafeRefPool = le_mem_CreatePool("ScanInformationSafeRefPool", sizeof(le_mrc_ScanInformationSafeRef_t)); // Create the Safe Reference Map to use for Scan Information List object Safe References. ScanInformationListRefMap = le_ref_CreateMap("ScanInformationListMap", MRC_MAX_SCANLIST); // Create the Safe Reference Map to use for Scan Information List object Safe References. ScanInformationRefMap = le_ref_CreateMap("ScanInformationMap", MRC_MAX_SCAN); // Register a handler function for new Registration State indication LE_DEBUG("Add pa_mrc_SetNetworkRegHandler"); LE_FATAL_IF((pa_mrc_AddNetworkRegHandler(NewRegStateHandler) == NULL), "Add pa_mrc_AddNetworkRegHandler failed"); // Get & Set the Network registration state notification LE_DEBUG("Get the Network registration state notification configuration"); result=pa_mrc_GetNetworkRegConfig(&setting); if ((result != LE_OK) || (setting == PA_MRC_DISABLE_REG_NOTIFICATION)) { LE_ERROR_IF((result != LE_OK), "Fails to get the Network registration state notification configuration"); LE_INFO("Enable the Network registration state notification"); LE_FATAL_IF((pa_mrc_ConfigureNetworkReg(PA_MRC_ENABLE_REG_NOTIFICATION) != LE_OK), "Enable the Network registration state notification failure"); } LoadMrcConfigurationFromConfigDB(); }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_AsyncSendText ( void ) { le_result_t res; bool pdu_type = false; NbSmsTx = NB_SMS_ASYNC_TO_SEND * 2 ; // Init the semaphore for asynchronous callback sem_init(&SmsTxSynchronization,0,0); TxCallBack = le_thread_Create("Tx CallBack", MyTxThread, &pdu_type); le_thread_Start(TxCallBack); res = WaitFunction(&SmsTxSynchronization, 120000); LE_ERROR_IF(res != LE_OK, "SYNC FAILED"); le_thread_Cancel(TxCallBack); return res; }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_Send_UCS2 ( void ) { le_result_t res = LE_FAULT; le_sms_MsgRef_t myMsg; NbSmsRx = 1; // Init the semaphore for synchronous API (hangup, answer) sem_init(&SmsRxSynchronization,0,0); RxThread = le_thread_Create("Rx SMS reception", MyRxThread, NULL); le_thread_Start(RxThread); // Wait for thread starting. sleep(2); // Check if Thread SMS RX handler has been started if (!RxHdlrRef) { LE_ERROR("Handler not ready !!"); return LE_FAULT; } myMsg = le_sms_Create(); if (myMsg) { LE_DEBUG("-TEST- Create Msg %p", myMsg); res = le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_SetUCS2(myMsg, UCS2_TEST_PATTERN, sizeof(UCS2_TEST_PATTERN) / 2); if (res != LE_OK) { le_sms_Delete(myMsg); return LE_FAULT; } res = le_sms_Send(myMsg); if ((res == LE_FAULT) || (res == LE_FORMAT_ERROR)) { le_sms_Delete(myMsg); return LE_FAULT; } res = WaitFunction(&SmsRxSynchronization, 120000); LE_ERROR_IF(res != LE_OK, "SYNC FAILED"); le_sms_Delete(myMsg); } le_sms_RemoveRxMessageHandler(RxHdlrRef); le_thread_Cancel(RxThread); return res; }
//-------------------------------------------------------------------------------------------------- static void StartSession ( uint32_t paxCount, ///< [IN] number of passengers int32_t hMinAccuracy, ///< [IN] minimum horizontal accuracy to trust the position (in meters) int32_t dirMinAccuracy ///< [IN] minimum direction accuracy to trust the position (in degrees) ) { bool isPosTrusted = false; int32_t latitude = 0x7FFFFFFF; int32_t longitude = 0x7FFFFFFF; int32_t hAccuracy = 0; int32_t direction = 0x7FFFFFFF; int32_t dirAccuracy = 0; LE_DEBUG("StartSession called"); if (ECallRef) { LE_WARN("End and Delete previous eCall session."); le_ecall_End(ECallRef); le_ecall_Delete(ECallRef); ECallRef = NULL; } ECallRef=le_ecall_Create(); LE_FATAL_IF((!ECallRef), "Unable to create an eCall object, exit the app!"); LE_DEBUG("Create eCallRef.%p", ECallRef); // Get the position data if ((le_pos_Get2DLocation(&latitude, &longitude, &hAccuracy) == LE_OK) && (le_pos_GetDirection(&direction, &dirAccuracy) == LE_OK)) { if ((hAccuracy < hMinAccuracy) && (dirAccuracy < dirMinAccuracy)) { isPosTrusted = true; LE_INFO("Position can be trusted."); } else { LE_WARN("Position can't be trusted!"); } } else { LE_WARN("Position can't be trusted!"); } LE_ERROR_IF((le_ecall_SetMsdPosition(ECallRef, isPosTrusted, latitude, longitude, direction) != LE_OK), "Unable to set the position!"); if (paxCount > 0) { LE_ERROR_IF((le_ecall_SetMsdPassengersCount(ECallRef, paxCount) != LE_OK), "Unable to set the number of passengers!"); } LE_ERROR_IF((le_ecall_StartTest(ECallRef) != LE_OK), "Unable to start an eCall, try again!"); LE_INFO("Test eCall has been successfully triggered."); }
//-------------------------------------------------------------------------------------------------- static void ConnectAudio ( void ) { le_result_t res; MdmRxAudioRef = le_audio_OpenModemVoiceRx(); LE_ERROR_IF((MdmRxAudioRef==NULL), "OpenModemVoiceRx returns NULL!"); MdmTxAudioRef = le_audio_OpenModemVoiceTx(); LE_ERROR_IF((MdmTxAudioRef==NULL), "OpenModemVoiceTx returns NULL!"); #if (ENABLE_CODEC == 1) // Redirect audio to the in-built Microphone and Speaker. FeOutRef = le_audio_OpenSpeaker(); LE_ERROR_IF((FeOutRef==NULL), "OpenSpeaker returns NULL!"); FeInRef = le_audio_OpenMic(); LE_ERROR_IF((FeInRef==NULL), "OpenMic returns NULL!"); #else // Redirect audio to the PCM interface. FeOutRef = le_audio_OpenPcmTx(0); LE_ERROR_IF((FeOutRef==NULL), "OpenPcmTx returns NULL!"); FeInRef = le_audio_OpenPcmRx(0); LE_ERROR_IF((FeInRef==NULL), "OpenPcmRx returns NULL!"); #endif AudioInputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioInputConnectorRef==NULL), "AudioInputConnectorRef is NULL!"); AudioOutputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioOutputConnectorRef==NULL), "AudioOutputConnectorRef is NULL!"); if (MdmRxAudioRef && MdmTxAudioRef && FeOutRef && FeInRef && AudioInputConnectorRef && AudioOutputConnectorRef) { res = le_audio_Connect(AudioInputConnectorRef, FeInRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect Mic on Input connector!"); res = le_audio_Connect(AudioInputConnectorRef, MdmTxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmTx on Input connector!"); res = le_audio_Connect(AudioOutputConnectorRef, FeOutRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect Speaker on Output connector!"); res = le_audio_Connect(AudioOutputConnectorRef, MdmRxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmRx on Output connector!"); } }
static void DisconnectAllAudio ( le_voicecall_CallRef_t reference ) { LE_DEBUG("DisconnectAllAudio"); MdmRxAudioRef = le_voicecall_GetRxAudioStream(reference); LE_ERROR_IF((MdmRxAudioRef==NULL), "le_voicecall_GetRxAudioStream returns NULL!"); MdmTxAudioRef = le_voicecall_GetTxAudioStream(reference); LE_ERROR_IF((MdmTxAudioRef==NULL), "le_voicecall_GetRxAudioStream returns NULL!"); if (AudioInputConnectorRef) { LE_INFO("Disconnect %p from connector.%p", FeInRef, AudioInputConnectorRef); if (FeInRef) { LE_INFO("Disconnect %p from connector.%p", FeInRef, AudioInputConnectorRef); le_audio_Disconnect(AudioInputConnectorRef, FeInRef); } if(MdmTxAudioRef) { LE_INFO("Disconnect %p from connector.%p", MdmTxAudioRef, AudioInputConnectorRef); le_audio_Disconnect(AudioInputConnectorRef, MdmTxAudioRef); } } if(AudioOutputConnectorRef) { LE_INFO("le_audio_Disconnect %p from connector.%p", MdmTxAudioRef, AudioOutputConnectorRef); if(FeOutRef) { LE_INFO("Disconnect %p from connector.%p", FeOutRef, AudioOutputConnectorRef); le_audio_Disconnect(AudioOutputConnectorRef, FeOutRef); } if(MdmRxAudioRef) { LE_INFO("Disconnect %p from connector.%p", MdmRxAudioRef, AudioOutputConnectorRef); le_audio_Disconnect(AudioOutputConnectorRef, MdmRxAudioRef); } } if(AudioInputConnectorRef) { le_audio_DeleteConnector(AudioInputConnectorRef); AudioInputConnectorRef = NULL; } if(AudioOutputConnectorRef) { le_audio_DeleteConnector(AudioOutputConnectorRef); AudioOutputConnectorRef = NULL; } if(FeInRef) { le_audio_Close(FeInRef); FeInRef = NULL; } if(FeOutRef) { le_audio_Close(FeOutRef); FeOutRef = NULL; } if(MdmRxAudioRef) { le_audio_Close(MdmRxAudioRef); MdmRxAudioRef = NULL; } if(MdmTxAudioRef) { le_audio_Close(MdmTxAudioRef); MdmTxAudioRef = NULL; } }
//-------------------------------------------------------------------------------------------------- static void MyCallEventHandler ( le_mcc_CallRef_t callRef, le_mcc_Event_t callEvent, void* contextPtr ) { le_result_t res; if (callEvent == LE_MCC_EVENT_ALERTING) { LE_INFO("Call event is LE_MCC_EVENT_ALERTING."); StopFilePlayback(); PlayFile(RINGTONE, true); } else if (callEvent == LE_MCC_EVENT_CONNECTED) { LE_INFO("Call event is LE_MCC_EVENT_CONNECTED."); StopFilePlayback(); // Connect voice call to audio res = le_audio_Connect(AudioInputConnectorRef, MdmTxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmTx on Input connector!"); res = le_audio_Connect(AudioOutputConnectorRef, MdmRxAudioRef); LE_ERROR_IF((res!=LE_OK), "Failed to connect mdmRx on Output connector!"); } else if (callEvent == LE_MCC_EVENT_TERMINATED) { LE_INFO("Call event is LE_MCC_EVENT_TERMINATED."); le_mcc_TerminationReason_t term = le_mcc_GetTerminationReason(callRef); switch(term) { case LE_MCC_TERM_LOCAL_ENDED: case LE_MCC_TERM_REMOTE_ENDED: LE_INFO("Termination reason is LE_MCC_TERM_REMOTE_ENDED or LE_MCC_TERM_LOCAL_ENDED"); break; case LE_MCC_TERM_NETWORK_FAIL: case LE_MCC_TERM_UNASSIGNED_NUMBER: case LE_MCC_TERM_USER_BUSY: case LE_MCC_TERM_UNDEFINED: default: LE_INFO("Termination reason is %d", term); StopFilePlayback(); break; } PlayFile(VOICE_PROMPT_END, false); le_mcc_Delete(callRef); if (callRef == TestCallRef) { TestCallRef = NULL; } } else if (callEvent == LE_MCC_EVENT_INCOMING) { LE_INFO("Call event is LE_MCC_EVENT_INCOMING."); } else { LE_INFO("Unknowm Call event."); } }
//-------------------------------------------------------------------------------------------------- static void ConnectAudio ( void ) { // Redirect audio to the in-built Microphone and Speaker. FeOutRef = le_audio_OpenSpeaker(); LE_ERROR_IF((FeOutRef==NULL), "OpenSpeaker returns NULL!"); FeInRef = le_audio_OpenMic(); LE_ERROR_IF((FeInRef==NULL), "OpenMic returns NULL!"); AudioInputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioInputConnectorRef==NULL), "AudioInputConnectorRef is NULL!"); AudioOutputConnectorRef = le_audio_CreateConnector(); LE_ERROR_IF((AudioOutputConnectorRef==NULL), "AudioOutputConnectorRef is NULL!"); LE_ERROR_IF((le_audio_Connect(AudioInputConnectorRef, FeInRef)!=LE_OK), "Failed to connect Mic on Input connector!"); LE_ERROR_IF((le_audio_Connect(AudioOutputConnectorRef, FeOutRef)!=LE_OK), "Failed to connect Speaker on Output connector!"); MdmRxAudioRef = le_audio_OpenModemVoiceRx(); LE_ERROR_IF((MdmRxAudioRef==NULL), "GetRxAudioStream returns NULL!"); MdmTxAudioRef = le_audio_OpenModemVoiceTx(); LE_ERROR_IF((MdmTxAudioRef==NULL), "GetTxAudioStream returns NULL!"); // Play local on output connector. PlayerRef = le_audio_OpenPlayer(); LE_ERROR_IF((PlayerRef==NULL), "OpenFilePlayback returns NULL!"); LE_ERROR_IF((le_audio_Connect(AudioOutputConnectorRef, PlayerRef) != LE_OK), "Failed to connect FilePlayback on output connector!"); MediaHandlerRef = le_audio_AddMediaHandler(PlayerRef, MyMediaEventHandler, NULL); LE_ERROR_IF((MediaHandlerRef==NULL), "AddMediaHandler returns NULL!"); // Set gains LE_ERROR_IF((le_audio_SetGain(PlayerRef, 1) != LE_OK), "Cannot set multimedia gain"); LE_ERROR_IF((le_audio_SetGain(FeInRef, 1) != LE_OK), "Cannot set microphone gain"); LE_ERROR_IF((le_audio_SetGain(MdmRxAudioRef, 12) != LE_OK), "Cannot set MdmRxAudioRef gain"); LE_ERROR_IF((le_audio_SetGain(MdmTxAudioRef, 12) != LE_OK), "Cannot set MdmTxAudioRef gain"); // Set specific gains for AR7/AR8 (won't work on other platforms) LE_ERROR_IF((le_audio_SetPlatformSpecificGain("D_AFE_GAIN_RX", 0x2000) != LE_OK), "Cannot set \"D_AFE_GAIN_RX\" gain"); LE_ERROR_IF((le_audio_SetPlatformSpecificGain("D_AFE_GAIN_TX", 0x2000) != LE_OK), "Cannot set \"D_AFE_GAIN_TX\" gain"); }