I want to play the file wavfile.h, but adl_audioStreamPlay return -7 which could be the problem? Thanks
#include "adl_global.h"
#include "wavfile.h"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;
const u32 wm_apmIRQLowLevelStackSize = 1024;
const u32 wm_apmIRQHighLevelStackSize = 1024;
static ascii * AUDIO_PLAY_CMD = "at+PLAY";
adl_atPort_e port_context = 0;
s32 appListenLowIrqHandle = 0;
s32 appListenHighIrqHandle = 0;
s32 appPlayLowIrqHandle = 0;
s32 appPlayHighIrqHandle = 0;
s32 record_resource_Handle = 0;
s32 play_resource_Handle = 0;
s32 appAudioSpeaker_Handle = 0;
#define SPEAKER 0
/***************************************************************************/
/* Local variables */
/***************************************************************************/
/***************************************************************************/
/* Function : appPlayLowIrqHandler */
/*-------------------------------------------------------------------------*/
/* Objet : IRQ low level handler */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* Source | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/* NotificationLevel | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/* Data | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
bool appPlayLowIrqHandler( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t *Data )
{
TRACE((1,"inside appPlayLowIrqHandler"));
// Call High level handler
return 1;
}
/***************************************************************************/
/* Function : appPlayHighIrqHandler */
/*-------------------------------------------------------------------------*/
/* Objet : IRQ high level handler */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* Source | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/* NotificationLevel | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/* Data | X | | | */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
bool appPlayHighIrqHandler( adl_irqID_e Source, adl_irqNotificationLevel_e NotificationLevel, adl_irqEventData_t *Data )
{
// This handler is called only to stop playing
s32 RetVal;
TRACE((1,"inside appPlayHighIrqHandler"));
// Stop playing
RetVal = adl_audioStop(play_resource_Handle);
if(RetVal != OK)
{
TRACE (( 1, "appPlayHighIrqHandler: OK not received for adl_audioStop/play: #%d", RetVal));
adl_atSendResponsePort(ADL_AT_RSP, port_context, "\r\nERROR:adl_audioStop for playing failed\r\n");
}
else
{
// Send OK
adl_atSendResponsePort(ADL_AT_RSP, port_context, "\r\nOK\r\n"); // OK FOR AT+PLAY
}
}
/***************************************************************************/
/* Local functions */
/***************************************************************************/
void app_PLAY_CmdHandler( adl_atCmdPreParser_t * paras )
{
u8 destination = 0;
s32 RetVal = 0;
//StreamBufferPlay = NULL;
destination = wm_atoi ( ADL_GET_PARAM ( paras, 0 ) );
port_context = paras->Port;
TRACE((1,"inside at+play"));
if(destination == SPEAKER){
TRACE (( 1, "app_PLAY_CmdHandler: SPEAKER" ));
play_resource_Handle = appAudioSpeaker_Handle;
}
else{
TRACE (( 1, "app_PLAY_CmdHandler: Bad option selected: #%d", destination ));
adl_atSendResponsePort(ADL_AT_RSP, port_context, "\r\nERROR:Bad destination selected: USAGE: <param1>: 0 - MICROPHONE, 1- GSM_RX <param2>:0 - SPEAKER, 1 - GSM_TX\r\n");
return;
}
TRACE((1,"sizeof du tab = %d", sizeof (audiosequence)));
// New audio play
adl_audioSetOption( play_resource_Handle, ADL_AUDIO_AMR_BUFFER_SIZE, sizeof (audiosequence) );
adl_audioSetOption( play_resource_Handle, ADL_AUDIO_AMR_MIXED_VOICE, FALSE );
adl_audioSetOption( play_resource_Handle, ADL_AUDIO_AMR_SPEECH_CODEC_RATE, ADL_AUDIO_AMR_RATE_12_20 );
RetVal = adl_audioStreamPlay ( play_resource_Handle, ADL_AUDIO_AMR , appPlayLowIrqHandle, appPlayHighIrqHandle, audiosequence);
if (RetVal != OK){
TRACE (( 1, "app_PLAY_CmdHandler: OK not received from adl_audioStreamPlay %d",RetVal));
adl_atSendResponsePort(ADL_AT_RSP, port_context, "\r\nERROR:adl_audioStreamPlay failed\r\n");
}
else{
TRACE((1,"OK received"));
}
}
void AudioEventHandler( s32 audioHandle, adl_audioEvents_e Event ) //add events
{
TRACE (( 1, "Inside the AudioEventHandler: Event :: %d", Event ));
return;
}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
// PCM Recorder an Player application
TRACE (( 1, "PCM_RecordAndPlay: Test Application" ));
TRACE (( 1, __DATE__ ));
TRACE (( 1, __TIME__ ));
// Subscribe to IRQ service
appPlayLowIrqHandle = adl_irqSubscribe ( appPlayLowIrqHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, ADL_IRQ_PRIORITY_LOW_LEVEL, 1 );
if( appListenLowIrqHandle < 0 )
TRACE (( 1, "Play Low IRQ handler subscription FAILED: %d ", appPlayLowIrqHandle ));
appPlayHighIrqHandle = adl_irqSubscribe ( appPlayHighIrqHandler, ADL_IRQ_NOTIFY_HIGH_LEVEL, ADL_IRQ_PRIORITY_HIGH_LEVEL, 1 );
if( appListenHighIrqHandle < 0 )
TRACE (( 1, "Play High IRQ handler subscription FAILED: %d ", appPlayHighIrqHandle ));
appAudioSpeaker_Handle = adl_audioSubscribe ( ADL_AUDIO_SPEAKER , AudioEventHandler, ADL_AUDIO_RESOURCE_OPTION_FORBID_PREEMPTION );
if(appAudioSpeaker_Handle < 0 )
TRACE (( 1, "ADL_AUDIO_SPEAKER cannot be subscribed: %d", appAudioSpeaker_Handle ));
/* Subscribe for AT+PLAY to play the recorded sound */
adl_atCmdSubscribe (AUDIO_PLAY_CMD, app_PLAY_CmdHandler, ADL_CMD_TYPE_PARA | 0x11 );
}