Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 4 - Speech Manager / Speech Manager Reference
Application-Defined Routines / Text-Done Callback Procedure


Legacy Documentclose button

Important: Inside Macintosh: Sound is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.

MyTextDoneCallback

A text-done callback procedure has the following syntax:

PROCEDURE MyTextDoneCallback 
                           (chan: SpeechChannel; refCon: LongInt; 
                           VAR nextBuf: Ptr; VAR byteLen: LongInt; 
                           VAR controlFlags: LongInt);
chan
The speech channel that has finished processing input text.
refCon
The reference constant associated with the speech channel.
nextBuf
On exit, a pointer to the next buffer of text to process or NIL if your application has no additional text to be spoken. This parameter is mostly for internal use by the Speech Manager.
byteLen
On exit, the number of bytes of the text buffer pointed to by the nextBuf parameter.
controlFlags
On exit, the control flags to be used in generating the next buffer of text.
DESCRIPTION
If a text-done callback procedure is installed in a speech channel, then the Speech Manager calls this procedure 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.

A common use of a text-done callback procedure 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 procedure that executes when speech is completed, see the definition of a speech-done callback procedure below.

Although most applications won't need to, your callback procedure can indicate to the Speech Manager whether there is another buffer of text to speak. If there is another buffer, your callback procedure should reference it by setting the nextBuf and byteLen parameters to appropriate values. (Your callback procedure 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 procedure should set nextBuf to NIL. In this case, the Speech Manager ignores the byteLen and controlFlags parameters.

If your text-done callback procedure does not change the values of the nextBuf and byteLen parameters, the text buffer just spoken will be spoken again.

SPECIAL CONSIDERATIONS
Because your callback procedure executes at interrupt time, you must not call any routines that might move or purge memory. If you are writing a callback procedure so that your application will know when it can dispose of a text buffer, then use the callback procedure to set a global flag variable. Your application's main event loop can check this flag and dispose of the text buffer if it is set.

Your callback procedure 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 application's A5 value by calling the SetSpeechInfo function with the soCurrentA5 selector.

ASSEMBLY-LANGUAGE INFORMATION
Because a callback procedure is called at interrupt time, it must preserve all registers other than A0-A2 and D0-D2.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996