[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] DisposeSpeechChannel?



>Is there any harm in exiting a MacPerl program that uses Mac::Speech, and
>that has opened and used one or more speech channels (NewSpeechChannel),
>without closing those channels (DisposeSpeechChannel) first?
>
>
>Feedback appreciated...

The short answer is yes, but...

from Inside Macintosh:

"Managing Speech Channels

To take advantage of any but the most rudimentary of the Speech Manager's 
capabilities, you need to use speech channels. However, you cannot create 
a speech channel simply by declaring a variable of type SpeechChannel. 
Before your application calls any routine that requires a speech channel 
as a parameter, you must call the NewSpeechChannel function to allow the 
Speech Manager to allocate memory associated with the speech channel. 
Later, you can release the memory occupied by a speech channel by calling 
the DisposeSpeechChannel function. In general, it is a good idea to 
create a speech channel just before you need it and then dispose of it as 
soon as you have finished processing speech through it."

My take on this:

It's a MacOS toolbox call.  Thus there is HARM in not doing what Apple 
considers a "good idea."  Basically, the memory remains allocated until 
you specifically deallocate it with (DisposeSpeechChannel).  Since this 
is external to MacPerl itself, MacPerl has no control over this behavior. 
 However:

from Inside Macintosh:

"The Speech Manager releases any speech channels that have not been 
explicitly disposed of by an application when the application quits. In 
general, however, your application should dispose of any speech channels 
it has created whenever it receives a suspend event. This ensures that 
other applications can take full advantage of Speech Manager and Sound 
Manager capabilities."

So, any harm done by not explicitly deallocating the speech channel will 
be limited to MacPerl. If you quit, the speech channel is disposed of.  
However, Apple likes you to play it safe, and not rely on this feature. I 
would say in context, that if you have two speech scripts, and the first 
doesn't call DisposeSpeechChannel before quitting, and you then run the 
second script, wihout quitting MacPerl, that there may be problems.

--B

# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org