Esempio n. 1
0
//--------------------------------------------------------------------------------------------------
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");
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
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!");
    }
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
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);
}