(Page 9 of 41 in this chapter) Version
vceCreateMemory
Description
- Allocates a memory block and assigns a voice handle to it.
Prototype
- DWORD vceCreateMemory ( CTAHD ctahd,
unsigned bytes,
unsigned encoding,
VCEHD *vh)
- ctahd Handle returned by ctaCreateContext.
- bytes Size of the memory block, in bytes.
- encoding Type of voice encoding of all data in the memory block.
- vh Pointer to a returned voice handle.
Return Values
Events
- None.
Details
- This function allocates a range of memory and assigns a voice handle to it. The size is specified in bytes.
- An open memory object initially has only one non-empty message, which is assigned message zero (0). The size of this message is equal to the size of the memory block. To record to a message other than message zero (0), either erase message zero (0) or resize it by recording or writing a message that is smaller than the entire memory block.
- If your memory block contains multiple messages, use vceDefineMessages to tell the Voice Message service how the memory is partitioned.
- Memory is always opened in PLAY_RECORD mode. There is no protection against opening overlapping memory regions. There is no interlock to prevent multiple threads recording to the same area from different contexts.
- Unlike voice files, memory objects cannot grow.
Note: Recording to a memory object will end with CTA_REASON_FINISHED if the message is bounded by the next message or if the end of the memory block is reached.
- Use vceClose to free memory, and release the handle and internal resources.
- Use vceRead to access data within the memory block.
- Unlike vceOpenMemory, vceCreateMemory can be used in either Library or Server mode.
See Also
- vceClose, vceRead
Example
/* myCreateMemory - Allocate a block of memory and get a voice handle to it. */
void myCreateMemory (CTAHD ctahd, unsigned maxtime, unsigned encoding, VCEHD *vh)
{
unsigned framesize;
unsigned frametime;
unsigned bytes;
unsigned ret;
vceGetEncodingInfo (ctahd, encoding, &framesize, &frametime);
bytes = maxtime/frametime * framesize;
ret = vceCreateMemory (ctahd, bytes, encoding, vh);
if (ret != SUCCESS)
{
char textbuf[80];
ctaGetText (ctahd, ret, textbuf, sizeof(textbuf));
printf("Error creating memory: error %s from vceCreateMemory\n",
textbuf);
}
}
(Page 9 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.