Voice API Programming Guide — June 2005 145
Cached Prompt Managementdevh[i] = dx_open(&szBoardName[offset],0);
}
//Step 4 Download the prompts to a board after determining available cache size
int nCacheSize;
int result;
int promptHandle; /* Handle of the prompt to be downloaded */
int fd1; /* First file descriptor for file to be downloaded */
int fd2; /* Second file descriptor for file to be downloaded */
DX_IOTT iott[2]; /* I/O transfer table to download cache prompt */
int totalfilesize;
result = dx_getcachesize(&devh[0], &nCacheSize, DX_CACHEREMAINING);
fd1 = open("HELLO.VOX", O_RDONLY); /* (Linux only) */
fd2 = open("GREETINGS.VOX", O_RDONLY); /* (Linux only) */
fd1 = dx_fileopen("HELLO.VOX", O_RDONLY|O_BINARY, 0); /* (Windows only) */
fd2 = dx_fileopen("GREETINGS.VOX", O_RDONLY|O_BINARY, 0); /* (Windows only) */
totalfilesize = _lseek(fd1, 0L, SEEK_END);
totalfilesize += _lseek(fd2, 0L, SEEK_END);
if (nCacheSize > totalfilesize) {
/* Set up DX_IOTT */
/*This block specifies the first data file */
iott[0].io_fhandle = fd1;
iott[0].io_offset = 0;
iott[0].io_length = -1;
iott[0].io_type = IO_DEV | IO_CONT;
/*This block specifies the second data file */
iott[1].io_fhandle = fd2;
iott[1].io_offset = 0;
iott[1].io_length = -1;
iott[1].io_type = IO_DEV | IO_EOT
/* Download the prompts to the on-board memory */
int promptHandle;
int result = dx_cacheprompt(brdhdl, iott, &promptHandle, EV_SYNC);
}
//Step 4 can be carried out with different prompts as long as the total filesize is less the
available nCacheSize. Also this can be extended to other boards in the system.
//Step 5 Download any combination of files from multiple sources
int fd; /* file descriptor for file to be played */
DX_IOTT iottplay[2]; /* I/O transfer table for the play operation*/
DV_TPT tpt; /* termination parameter table */
DX_XPB xpb; /* I/O transfer parameter block */
.
.
.
/* Open channel */
if ((chdev = dx_open("dxxxB1C1",0)) == -1) {
printf("Cannot open channel\n");
/* Perform system error processing */
exit(1);
}
/* Set to terminate play on 1 digit */
tpt.tp_type = IO_EOT;
tpt.tp_termno = DX_MAXDTMF;
tpt.tp_length = 1;