Using synchronous foreground operations

In synchronous foreground operations, the state table controls the voice channel, and uses the RecordVoiceToHost or PlayVoiceFromHost state table actions to tell the custom server when the voice channel can be used, and specifies the DTMF stop keys.

The state table invokes a user function (using the RecordVoiceToHost or PlayVoiceFromHost actions) to request a custom server to play or record voice data on a channel. To control the channel, use the following custom server subroutines in the user function:

CA_Open_Channel()
To open a voice channel owned by the channel process. For more information see CA_Open_Channel().
CA_Close_Channel()
To close a voice channel owned by the channel process. For more information see CA_Close_Channel().

Recording voice data

To start direct access to a voice channel, use the CA_Open_Channel() subroutine and indicate that it is for a READ operation. If the channel is opened successfully, information about the voice channel is returned. This information is used as input to subsequent custom server subroutines.

Data can be read from the channel either in blocking mode, using the CA_Record_Voice_Stream() subroutine in CA_WAIT mode, or, in non-blocking mode, using the CA_Record_Voice_Stream() subroutine in CA_NOWAIT mode and with CA_Poll() monitoring when there is data available to read.

Use CA_Close_Channel() to close the channel when:

When the custom server issues CA_Close_Channel() and there is still data to be read, the RecordVoiceToHost state table action completes, and the next state table action is executed.

The asynchronous method is recommended for recording voice data, because it gives greater flexibility and control, and also supports barge-in.

Playing voice data

To start direct access to a voice channel, use the CA_Open_Channel() subroutine and indicate that it is for a WRITE operation. If the channel is opened successfully, information about the voice channel is returned. This information is used as input to subsequent custom server subroutines.

Data can be written to the channel either in blocking mode, using the CA_Play_Voice_Elements() or CA_Play_Voice_Stream() subroutine in CA_WAIT mode, or in non-blocking mode, using the CA_Play_Voice_Elements() or CA_Play_Voice_Stream() subroutine in CA_NOWAIT mode and with CA_Poll() monitoring when data should be written to prevent an overrun condition.

Use CA_Close_Channel() to close the channel when:

When the custom server issues the CA_Close_Channel(), and there has not been an error, the PlayVoiceFromHost state table action completes, and the next state table action is executed.