Stream to TX Line

Hi all,

in my application I want to play an audio stream for caller by the Q2686. The audio data is encoded with AMR…

Using the example from the document as base I tried the following code:

// audio resource handle
s32 handle;
// audio stream buffer
void * StreamBuffer;
// Low level interruption handler
bool MyLowLevelIRQHandler ( adl_irqID_e Source, adl_irqNotificationLevel_e Notification_Level, adl_irqEventData_t * Data )
{
    // copy PCM sample to play
    wm_strcpy( StreamBuffer, audio_data );
    return FALSE;
}
// audio event call-back function
void MyAudioEventHandler ( s32 audioHandle, adl_audioEvents_e Event )
{
    ascii TextBuffer[128] ;
    wm_sprintf(TextBuffer, "Audio handle %d\r\n", Event) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
    return;
}

void test()
{
    ascii TextBuffer[128] ;
    s32 Ret;
    s32 BufferSize = AUDIO_DATA_SIZE;
    bool MixedOption = FALSE;
    adl_audioAmrCodecRate_e CodecRate = ADL_AUDIO_AMR_RATE_5_90;
    // Subscribe to the current speaker
    handle = adl_audioSubscribe ( ADL_AUDIO_VOICE_CALL_TX, MyAudioEventHandler , ADL_AUDIO_RESOURCE_OPTION_FORBID_PREEMPTION );
    wm_sprintf(TextBuffer, "Audio handle %d\r\n", handle) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
    // Set Mixed voice option
    Ret = adl_audioSetOption ( handle, ADL_AUDIO_AMR_MIXED_VOICE, &MixedOption );
    wm_sprintf(TextBuffer, "Option %d\r\n", Ret) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
    // Set Codec Rate
    Ret = adl_audioSetOption ( handle, ADL_AUDIO_AMR_SPEECH_CODEC_RATE, &CodecRate );
    wm_sprintf(TextBuffer, "Option %d\r\n", Ret) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
    // Memory allocation
    Ret = adl_audioSetOption ( handle, ADL_AUDIO_AMR_BUFFER_SIZE, &BufferSize );
    wm_sprintf(TextBuffer, "Option %d\r\n", Ret) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
    
    StreamBuffer = adl_memGet( BufferSize ); // release memory after audio stream playing
    // Play an audio AMR stream
    Ret = adl_audioStreamPlay( handle, ADL_AUDIO_AMR, MyLowLevelIRQHandler, 0, StreamBuffer);
    wm_sprintf(TextBuffer, "Play %d\r\n", Ret) ;
    adl_atSendResponse ( ADL_AT_UNS, TextBuffer);
}

The resulting output is:

Audio handle 403451560
Option -2
Option -2
Option 0
Play -7

A call has been established by adl_callAnswer() and the ADL_CALL_EVENT_AUDIO_OPENNED and the ADL_CALL_EVENT_ANSWER_OK events were hit. Any suggestions what I am doing wrong?

Best regards
fgeyer