Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 2 - Sound Manager / Sound Manager Reference
Sound Manager Routines / Allocating and Releasing Sound Channels


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.

SndDisposeChannel

If you allocate a sound channel by calling the SndNewChannel function, you must release the memory it occupies by calling the SndDisposeChannel function.

FUNCTION SndDisposeChannel (chan: SndChannelPtr; 
                              quietNow: Boolean): OSErr;
chan
A pointer to a valid sound channel record.
quietNow
A Boolean value that indicates whether the channel should be disposed immediately (TRUE) or after sound stops playing (FALSE).
DESCRIPTION
The SndDisposeChannel function disposes of the queue of sound commands associated with the sound channel specified in the chan parameter. If your application created its own sound channel record in memory or installed a sound as a voice in a channel, the Sound Manager does not dispose of that memory. The Sound Manager also does not release memory associated with a sound resource that you have played on a channel. You might use the userInfo field of the sound channel record to store the address of a sound handle you wish to release before disposing of the sound channel itself.

The SndDisposeChannel function can dispose of a channel immediately or wait until the queued commands are processed. If quietNow is set to TRUE, a flushCmd command and then a quietCmd command are sent to the channel bypassing the command queue. This removes all commands, stops any sound in progress, and closes the channel. If quietNow is set to FALSE, then the Sound Manager issues a quietCmd command only; it does not bypass the command queue, and it waits until the quietCmd command is processed before disposing of the channel.

SPECIAL CONSIDERATIONS
Because the SndDisposeChannel function might dispose of memory, you should not call it at interrupt time.

RESULT CODES
noErr0No error
badChannel-205Channel is corrupt or unusable

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996