TTS_SOURCE_CB
Invoked when you enable the input streaming mode on the engine instance.
typedef TTSRETVAL (*TTS_SOURCE_CB)(
LH_VOID* pAppData,
LH_VOID* pInputBuffer,
LH_U32 cInputBufferAlloc,
LH_U32* pcInputBuffer);
Argument |
Description |
---|---|
pAppData |
Application data pointer that was passed into TtsOpen. |
pInputBuffer |
[out] Pointer to a data buffer that is to be filled with the input text. This buffer is provided by the callback function, no need to allocate memory for it. |
cInputBufferAlloc |
Size in bytes of the buffer pointed to by pInputBuffer. This is the maximum amount of data that can be placed in pInputBuffer. |
pcInputBuffer |
[out] Number of bytes that were actually placed in the buffer. |
The engine instance uses this callback to request a block of input text from the application: it calls the function multiple times to allow the application to deliver unlimited data for the current TTS action.
Whenever the application puts data into pInputBuffer, expect the function return TTS_SUCCESS. When there is no additional input data, expect the function to return TTS_ENDOFDATA. Then, the TTS engine knows the previous input corresponded with the last input block for a speak action and no longer invokes the callback for the remainder of the TtsProcessEx function (in other words, until the function returns). Any data in the buffer when TTS_ENDOFDATA is returned is ignored.
To register your callback, see TTS_OPEN_PARAMS.
Return values:
- TTS_SUCCESS
- TTS_ENDOFDATA
Note: Do not register this callback unless the uri and data member of the TTS_SPEAK_DATA structure can be NULL. This approach makes it possible to combine the TtsSource source callback function with the TtsProcessEx function.
When using the source callback method, the input text must be encoded with the character set indicated by the TTS_SPEAK_DATA structure passed to TtsProcessEx. See TTS_SPEAK_DATA.