Writes data at the current position in the current message.
DWORD vceWrite ( CTAHD ctahd, BYTE *buffer, unsigned bytes, unsigned insertmode, unsigned *byteswritten)
|
Argument |
Description |
|
ctahd |
Handle returned by ctaCreateContext or ctaAttachContext. |
|
buffer |
Pointer to a buffer of data to write. |
|
bytes |
Amount of data to write. |
|
insertmode |
VCE_OVERWRITE or VCE_INSERT. |
|
byteswritten |
Pointer to the returned number of bytes written. |
|
Return value |
Description |
|
SUCCESS |
|
|
CTAERR_DISK_FULL |
There is not enough room on the disk to complete the write operation. No data was written. |
|
CTAERR_FUNCTION_ACTIVE |
Playing or recording is already active on the context. |
|
CTAERR_INVALID_CTAHD |
Context handle is invalid. |
|
CTAERR_SVR_COMM |
Server communication error. |
|
VCEERR_INVALID_OPERATION |
File type of the current message does not support insertion anywhere except at the end of a message. The operation is also invalid if the current message is a list. |
|
VCEERR_NO_MESSAGE |
Context contains no current message. |
|
VCEERR_NO_SPACE |
Insufficient room in the destination message. |
|
VCEERR_OUT_OF_INDICES |
Destination VOX file contains no free header entries. |
|
VCEERR_PLAY_ONLY |
Voice file was not opened for record. |
vceWrite copies the specified number of bytes of data from buffer to the current location in the current message of the context that ctahd specified. This function returns the number of bytes of data written in byteswritten, unless byteswritten is NULL.
EDTX encoding types are not supported.
Set insertmode to VCE_OVERWRITE to replace existing data without changing the message size. In overwrite mode, if you attempt to write beyond the end of the current message, SUCCESS is returned and the current position is set to the end of the current message.
Set insertmode to VCE_INSERT to insert new data before the current position. If the current position is the end of the message, VCE_INSERT appends the new data to the current message. Inserting data anywhere except at the end of a message is allowed only on file types that support editing (currently only VOX files).
On completion, the current position is after the inserted data for either insert mode. The current position is advanced by the amount written, in millisecond units.
To convert between bytes and milliseconds, use vceGetContextInfo to get the frame size and frame time, and then use the following formulas:
bytes = ( milliseconds / frametime ) * framesize
milliseconds = ( bytes / framesize ) * frametime
/* Append one message to another */
void myMsgCat (CTAHD ctahd, VCEHD destvh, unsigned destmsg,
VCEHD srcvh, unsigned srcmsg)
{
BYTE *buffer;
unsigned msec;
unsigned bytes;
unsigned byteswritten;
/* Read source message to memory - see example in vceRead */
myLoadMessage (ctahd, srcvh, srcmsg, &buffer, &msec, &bytes);
/* Seek to end of destination */
vceSetCurrentMessage (destvh, destmsg);
vceSetPosition (ctahd, 0, VCE_SEEK_END, NULL);
/* Append source message */
vceWrite (ctahd, buffer, bytes, VCE_INSERT, &byteswritten);
/* Release temporary buffer */
free (buffer);
if (byteswritten < bytes)
printf("Insufficient space");
return;
}