Releasing Sound Channels
Releasing Sound Channels
To release a sound channel that you have allocated with SndNewChannel, use
SndDisposeChannel. SndDisposeChannel requires two parameters, a
pointer to the channel that is to be disposed and a Boolean value that indicates
whether the channel should be flushed before disposal. Here's an example:
myErr= SndDisposeChannel( mySndChan, TRUE);
Because the second parameter is TRUE, the Sound Manager sends both a
flushCmd command and a quietCmd command to the sound channel ( using
SndDoImmediate). This removes all commands from the sound channel and
stops any sound already in progress. Then the Sound Manager disposes of the
channel.
If the second parameter is FALSE, the Sound Manager simply queues a
quietCmd command (using SndDoCommand) and waits until quietCmd is
received by the synthesizer before disposing of the channel. In this case, the
call to SndDisposeChannel is synchronous.
Note: It is important to remember that sound channels are for
temporary use and that you should create them just before playing
sounds. Once the sound is completed, you should dispose of the
channel. One reason for this is that only one playback synthe-sizer
can be active at any time. If your application is switched into the
background and does not release a sound channel, then other
applications are unable to open channels linked to other synthesizers.
In particular, the system alert sound may not be heard and the user
may not be notified of important system occurrences.