![]() |
SpeechTextDoneProcPtr |
||||
Header: | SpeechSynthesis.h | Carbon status: | Supported | |
Defines a pointer to a text-done callback function. Your text-done function is called when the Speech Manager has finished processing a buffer of text.
typedef void(* SpeechTextDoneProcPtr) ( SpeechChannel chan, SInt32 refCon, void **nextBuf, UInt32 *byteLen, SInt32 *controlFlags );
You would declare your function like this if you were to name it MySpeechTextDoneCallback:
void MySpeechTextDoneCallback ( SpeechChannel chan, SInt32 refCon, void **nextBuf, UInt32 *byteLen, SInt32 *controlFlags );
The speech channel that has finished processing input text.
The reference constant associated with the speech channel.
On return, a pointer to the next buffer of text to process or NULL if your application has no additional text to be spoken. This parameter is mostly for internal use by the Speech Manager.
On return, a pointer to the number of bytes of the text buffer pointed to by the nextBuf parameter.
On return, a pointer to the control flags to be used in generating the next buffer of text.
If a text-done callback function is installed in a speech channel, then the Speech Manager calls this function when it finishes processing a buffer of text. The Speech Manager might not yet have completed finishing speaking the text and indeed might not have started speaking it.
You can specify a text-done callback procedure by passing the soTextDoneCallBack selector to the SetSpeechInfo function.
A common use of a text-done callback function is to alert your application once the text passed to the SpeakText or SpeakBuffer function can be disposed of (or, when the text is contained within a locked relocatable block, when the relocatable block can be unlocked). The Speech Manager copies the text you pass to the SpeakText or SpeakBuffer function into an internal buffer. Once it has finished processing the text, you may dispose of the original text buffer, even if speech is not yet complete. However, if you wish to write a callback function that executes when speech is completed, see the definition of a speech-done callback function below.
Although most applications will not need to, your callback function can indicate to the Speech Manager whether there is another buffer of text to speak. If there is another buffer, your callback function should reference it by setting the nextBuf and byteLen parameters to appropriate values. (Your callback function might also change the control flags to be used to process the speech by altering the value in the controlFlags parameter.) Setting these parameters allows the Speech Manager to generate uninterrupted speech. If there is no more text to speak, your callback function should set nextBuf to NULL. In this case, the Speech Manager ignores the byteLen and controlFlags parameters.
If your text-done callback function does not change the values of the nextBuf and byteLen parameters, the text buffer just spoken will be spoken again.
Because your callback function executes at interrupt time, you must not call any functions that might move or purge memory. If you are writing a callback function so that your application will know when it can dispose of a text buffer, then use the callback function to set a global flag variable. Your applications main event loop can check this flag and dispose of the text buffer if it is set.
Your callback function is able to access application global variables only if the A5 register is properly set. The Speech Manager sets A5 to the proper value if you provide your applications A5 value by calling the SetSpeechInfo function with the soCurrentA5 selector.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)