//-------------------------------------------------------------------------------------------------- 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"); }
//-------------------------------------------------------------------------------------------------- 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"); } } }