Teminating Events
Previous Topic  Next Topic 

Many of the speech functions such as SMplay() and SMrecord() will cause the calling task to block until the function completes with a terminating event (unless SMmode() is called to allow non-blocking functionality).       


The list of blocking functions for which terminating events apply are listed below:


SMplay(vox_chan,filename[,mode,sample_rate])

SMplayh(vox_chan,filehandle[bytes,mode,sample_rate])

SMrecord(vox_chan,filename,[seconds,silence,mode,sample_rate,beep])

SMwaittones(vox_chan,max_tones,first_delay10ths,inter_delay10ths[,term_digits,&num_digits])

SMplaytone(vox_chan,toneid,duration_ms)

SMplaydigits(vox_chan,digit_str,[inter_delay_ms,dig_dur_ms])

SMplaycptone(vox_chan,duration_ms,type,tone_id1,on_cad1,off_cad1[,tone_id2,on_cad2,off_cad2.....])

SMgetrecognised(vox_chan,timeout,&type,&param0,&param1)

SMplayph(vox_chan[,slot, dataformat, samplerate])

SMplaypr(vox_chan,slot, prompt_no [,dataformat, samplerate])


There are a number of different reasons why a function might terminate such as reaching the end of the file or a DTMF digit being received etc.      The full list of possible terminating events for all blocking speech functions are shown below (as defined in ACULAB.INC):


# Terminating events

const TERM_ERROR       = -1;

const TERM_TONE        = 1;

const TERM_MAXDTMF     = 2;

const TERM_TIMEOUT     = 3;

const TERM_INTERDELAY  = 4;

const TERM_SILENCE     = 5;

const TERM_ABORT       = 6;

const TERM_EODATA      = 7;

const TERM_PLAYTONE    = 8;

const TERM_PLAYDIGITS  = 9;

const TERM_PLAYCPTONE  = 10;

const TERM_RECOG       = 11;


The following table gives a description of each of these terminating events and the function for which they apply:


Event Name

Description

Applies to functions

TERM_ERROR

An error of some kind was encountered

ALL

TERM_TONE

The function was terminated by a DTMF digit

SMplay(); SMplayh(); SMplayph(); SMplaypr(); SMrecord(); SMwaittones(); SMplaytone(); SMplaycptone()

TERM_MAXDTMF

The total number of DTMF digits requested has been received

SMwaittones()

TERM_TIMEOUT

A timeout has occurred

SMwaittones(); SMwaitrecog(); SMrecord()

TERM_INTERDELAY

The specified inter-digit delay timeout has occurred

SMwaittones()

TERM_SILENCE

The specified period of silence has occurred

SMrecord()

TERM_ABORT

The function was aborted by SMabort()

ALL

TERM_EODATA

End of file or data has been reached.

SMplay(); SMplayh(); SMplayph(); SMplaypr(); SMrecord()

TERM_PLAYTONE

The specified tone has finished playing

SMplaytone()

TERM_PLAYDIGITS

All specified digits have been played

SMplaydigits()

TERM_PLAYCPTONE

The specified call progresss tone has finished playing

SMplaycptone()

TERM_RECOG

A recognition event has been received (ASR,Grunt,CPtone etc)

SMgetrecognised()



Note:  When called in blocking mode (the default mode for a channel),  all of the above functions will also be terminated whenever a hangup signal is received that causes a jump to the onsignal function.              However there is no specific terminating event code for this type of termination since the return value from the function can never be retrieved when a hangup signal is received, since the program execution will immediately jump to the onsignal routine.


In non-blocking mode (see 1.4 below),   the above functions will not automatically be terminated by a jump to the onsignal function and must be manually aborted using the SMabort() function, or the application must manually wait for the function to complete by looping on the SMstate() function call and waiting for the state to return to 0 to indicate that the function has completed..