Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 2 - Sound Manager / Sound Manager Reference
Data Structures


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.

Sound Channel Records

The Sound Manager maintains a sound channel record to store information about each sound channel that you allocate directly by calling the SndNewChannel function or indirectly by passing a NIL channel to a high-level Sound Manager routine like the SndPlay function. The SndChannel data type defines a sound channel record.

TYPE SndChannel =
PACKED RECORD
   nextChan:      SndChannelPtr; {pointer to next channel}
   firstMod:      Ptr;           {used internally}
   callBack:      ProcPtr;       {pointer to callback procedure}
   userInfo:      LongInt;       {free for application's use}
   wait:          LongInt;       {used internally}
   cmdInProgress: SndCommand;    {used internally}
   flags:         Integer;       {used internally}
   qLength:       Integer;       {used internally}
   qHead:         Integer;       {used internally}
   qTail:         Integer;       {used internally}
   queue:         ARRAY[0..stdQLength-1] OF SndCommand;
END; 
Field Description
nextChan
A pointer to the next sound channel in a single queue of channels that the Sound Manager maintains for all applications.
firstMod
Used internally.
callBack
A pointer to the callback procedure associated with the sound channel. See page 2-152 for information on this callback procedure.
userInfo
A value that your application can use to store information.
wait
Used internally.
cmdInProgress
Used internally.
flags
Used internally.
qLength
Used internally.
qHead
Used internally.
qTail
Used internally.
queue
The sound commands pending for the sound channel.
The only field of the sound channel record that you are likely to need to access directly is the userInfo field. This field is useful if you need to pass a value to a Sound Manager callback procedure or completion routine. For example, you might pass the value stored in the A5 register so that your callback procedure can access your application's global variables. Or, you might store a handle to sound data here so that a routine that disposes of an allocated channel can also release the sound data that the channel played.

In rarer instances, you might need to access the callBack field of the sound channel record directly. Ordinarily, you set this field by specifying a callback procedure when you call the SndNewChannel function. However, you can change the callback procedure associated with a channel by changing this field directly. The Sound Manager will then execute the procedure you specify in this field whenever the channel processes a callBackCmd command.

WARNING
You should not attempt to manipulate all open sound channels by using the nextChan field to walk the sound channel queue. The queue might contain channels opened by other applications. If you need to perform some operation on all sound channels that your application has allocated, you should maintain your own data structure that keeps track of your application's channels.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996