Table of Contents Index NMS Glossary Previous Page Next Page (Page 24 of 41 in this chapter) Version


vceOpenMemory

Description

Assigns a voice handle to a memory block. Use in Library mode only.

Prototype

DWORD vceOpenMemory ( CTAHD ctahd,
BYTE *address,
unsigned bytes,
unsigned encoding
VCEHD *vh)

ctahd Handle returned by ctaCreateContext.

address Base address of the memory block in process space or shared memory.

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

Details

This function assigns a voice handle to a range of memory. The size is specified in bytes.

vceOpenMemory is not supported in Natural Access Server mode. In Server mode, use vceCreateMemory.

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 other than to 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.

vceClose releases the handle and internal resources.

Natural Access does not allocate the memory block in vceOpenMemory nor does it free it in vceClose.

See Also

vceAssignHandle, vceClose, vceCreateFile, vceDefineMessages, vceErase, vceEraseMessage, vceOpenFile

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;
void *address;

vceGetEncodingInfo (ctahd, encoding, &framesize, &frametime);
bytes = maxtime/frametime * framesize;
address = malloc (bytes);
vceOpenMemory (ctahd, address, bytes, encoding, vh);
}


Table of Contents Index NMS Glossary Previous Page Next Page (Page 24 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.