Using asynchronous background operation

In asynchronous background operations, the custom server controls the voice channel, and the state table uses SendData actions to tell the custom server when to start and stop the channel. The custom server specifies the DTMF stop keys, record buffers, and play buffers.

The state table invokes a user function, using the SendData action, to tell a custom server to start or stop recording voice data on a channel. You must use the following associated custom server subroutines in the user function:

CA_Open_Record_Channel()
To open a voice channel owned by the custom server. For more information see CA_Open_Record_Channel().
CA_Start_Record_Channel()
To start a voice channel owned by the custom server. For more information see CA_Start_Record_Channel().
CA_Record_Voice_Stream()
To read voice data from a voice channel owned by the custom server. For more information see CA_Record_Voice_Stream().
CA_Stop_Record_Channel()
To stop a voice channel owned by the custom server. For more information see CA_Stop_Record_Channel().
CA_Close_Record_Channel()
To close a voice channel owned by the custom server. For more information see CA_Close_Record_Channel().

Your custom server must specify the following (controlled by the channel process in the synchronous method):

Recording voice data

Use the CA_Open_Record_Channel() subroutine to access a voice channel directly. When the channel is opened successfully, information about the voice channel, used as input to subsequent custom server subroutines, is returned.

You must start the channel, using CA_Start_Record_Channel(), before voice data can be read, then data can be read in blocking mode, using the CA_Record_Voice_Stream() subroutine in CA_WAIT mode, or in non-blocking mode using CA_Record_Voice_Stream() subroutine in CA_NOWAIT mode and with CA_Poll() monitoring when there is data available to read.

Using the synchronous method, recording starts immediately after the CA_Open_Channel() subroutine. Using the asynchronous method, recording does not start until CA_Start_Record_Channel() is issued and the trigger event selected in the CA_Start_Record_Channel() has occurred.

Using CA_Start_Record_Channel() can improve performance, for example, if the trigger event is voice energy detection, the custom server does not need to process any voice data until the caller starts to speak.

Use CA_Stop_Record_Channel() to stop the voice channel record without closing it. To make another recording, restart the voice channel using CA_Start_Record_Channel().

Use CA_Close_Record_Channel() to close the channel when:

Use the CA_Report_Channel_Event() subroutine to pass information to the state table, as it is not automatically notified of the progress of the background record operation. For example, to tell the state table that the custom server has stopped the recording, or that an intermediate event has been detected.

The state table uses the WaitEvent action to detect this asynchronous indication.