144 Voice API Programming Guide — June 2005
Cached Prompt Management
12.3 Cached Prompt Management Example CodeThis example code illustrates one way to implement cached prompt management in your
application. It uses the following key steps, as indicated in the comments:
1. Get the AUIDs of all physical boards in the system.
2. Get the names of all physical boards for the corresponding AUIDs.
3. Open all physical board devices.
4. Download cached prompts to a physical board, after verifying that total available cache
memory is greater than total file size.
5. Play back any combination of files from multiple sources.
6. Shut down, free allocated memory, and close all opened devices.
The example code is provided next.
Note: In Linux, the device name must be in lowercase; for example, brdB1 and not BrdB1.
//Pseudo Application for Cached Prompts
#include "srllib.h"
#include "dxxxlib.h"
#include "malloc.h"
//Sytem Initialization
//Step 1 Get the AUID’s of all the Physical Boards in the system
AUID *pAU;
int iNumPhyBds;
long retVal;
iNumPhyBds = 0;
pAU = 0;
do
{
free(pAU);
pAU = iNumPhyBds ? (AUID *)malloc(iNumPhyBds * sizeof(*pAU)) : 0;
retVal = SRLGetAllPhysicalBoards(&iNumPhyBds, pAU);
} while (ESR_INSUFBUF == retVal);
if (ESR_NOERR != retVal)
{ // do some error handling
...
}
//Step 2 get all the names of the physical boards for the corresponding AUID’s and Step 3 - open
all the physical boards
int brdstrlen = 7;//say "brdB1"
char * szBoardName;
szBoardName = (char *) malloc (iNumPhyBds * brdstrlen * sizeof(char));
int offset=0;
int *devh;
devh = (int *)malloc(iNumPhyBds * sizeof(int));
for (int i= 0; i < iNumPhyBds; i++) {
offset = i * brdstrlen;
//Get the name of the board pointed to by the nth AUID
retval = SRLGetPhysicalBoardName(pAU[i], &brdstrlen, &szBoardName[offset]);