(Page 2 of 41 in this chapter) Version
vceAssignHandle
Description
- Assigns a voice handle to a file that has been opened by an application that is executing in Library mode.
Prototype
- DWORD vceAssignHandle ( CTAHD ctahd,
int filedes,
unsigned encoding,
VCEHD *vh)
- ctahd Handle returned by ctaCreateContext.
- filedes File descriptor returned by an operating system open function.
- encoding Encoding of all messages in the file.
- vh Pointer to a returned voice handle.
Return Values
E vents
Details
- This function assigns a voice handle to a file that is already opened or to some other data stream such as stdin.
- When the voice handle is closed with vceClose
, filedes is not automatically closed.
- The voice handle returned by vceAssignHandle is marked as thread-safe by the VCE service, so that multiple voice handles can be assigned to the same open file. This allows a common prompt file, for example, to be safely accessed by multiple contexts running in separate threads without incurring the overhead of multiple file opens.
- You can only record to or edit a file that has been opened for writing. Otherwise, the record or edit function returns a write failed error code.
Note: In UNIX, you can use the file descriptor returned by the C open function, or the C fileno function. Under Windows NT or Windows 2000, some compilers do not return the OS file descriptor, so you can only use file descriptors returned by system calls (for example, CreateFile).
- vceAssignHandle is not supported in Server mode. In Server mode, use vceOpenFile.
See Also
- vceClose
, vceCreateFile, vceOpenFile, vceOpenMemory
Example
/* Play from standard input */
#if defined _WIN32 && defined _MSC_VER
#include <io.h>
#define STDIN_FILENO _get_osfhandle (0)
#endif
extern CTAHD Ctahd;
extern CTAQUEUEHD CtaQueueHd;
void myplaystdin( unsigned encoding )
{
VCEHD vh;
CTA_EVENT event;
vceAssignHandle (Ctahd, STDIN_FILENO, encoding, &vh );
vcePlayMessage (vh, 0, NULL);
do
{
ctaWaitEvent( CtaQueueHd, &event, CTA_WAIT_FOREVER);
} while (event.id != VCEEVN_PLAY_DONE); /* Ignore other events */
}
(Page 2 of 41 in this chapter) Version
Want to send us feedback on our documentation? Email: Tech_Pubs@nmss.com
Copyright © 2001, Natural MicroSystems, Inc. All rights
reserved.