Intel 05-1832-002 IP Phone User Manual


 
304 Voice API for Windows Operating Systems Library Reference — November 2003
dx_play( ) — play recorded voice data
#define MAXCHAN 24
int play_handler();
DX_IOTT prompt[MAXCHAN];
DV_TPT tpt;
DV_DIGIT dig;
main()
{
int chdev[MAXCHAN], index, index1;
char *chname;
int i, srlmode, voxfd;
/* Set SRL to run in polled mode. */
srlmode = SR_POLLMODE;
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&srlmode) == -1) {
/* process error */
}
/* initialize all the DX_IOTT structures for each individual prompt */
.
.
/* Open the vox file to play; the file descriptor will be used
* by all channels.
*/
if ((voxfd = dx_fileopen("prompt.vox", O_RDONLY|O_BINARY)) == -1) {
/* process error */
}
/* For each channel, open the device using dx_open(), set up a DX_IOTT
* structure for each channel, and issue dx_play() in asynchronous mode. */
for (i=0; i<MAXCHAN; i++) {
/* Set chname to the channel name, e.g., dxxxB1C1, dxxxB1C2,... */
/* Open the device using dx_open( ). chdev[i] has channel device
* descriptor.
*/
if ((chdev[i] = dx_open(chname,NULL)) == -1) {
/* process error */
}
/* Use sr_enbhdlr() to set up handler function to handle play
* completion events on this channel.
*/
if (sr_enbhdlr(chdev[i], TDX_PLAY, play_handler) == -1) {
/* process error */
}
/* Set the DV_TPT structures up for MAXDTMF. Play until one digit is
* pressed or the file is played
*/
dx_clrtpt(&tpt,1);
tpt.tp_type = IO_EOT; /* only entry in the table */
tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */
tpt.tp_length = 1; /* terminate on the first digit */
tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */
prompt[i].io_type = IO_DEV|IO_EOT; /* play from file */
prompt[i].io_bufp = 0;
prompt[i].io_offset = 0;
prompt[i].io_length = -1; /* play till end of file */
prompt[i].io_nextp = NULL;
prompt[i].io_fhandle = voxfd;