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.
Creating an Audio Component
An audio component is a component. It contains a number of resources, including icons, strings, and the standard component resource (a resource of type'thng'
) required of any Component Manager component. In addition, an audio component must contain code to handle required selectors passed to it by the Component Manager as well as selectors specific to the audio component.
The component resource binds together all the relevant resources contained in a component; its structure is defined by the
- Note
- For complete details on components and their structure, see the chapter "Component Manager" in Inside Macintosh: More Macintosh Toolbox. This section provides specific information about audio components.
ComponentResource
data type.
struct ComponentResource { ComponentDescription cd; ResourceSpec component; ResourceSpec componentName ResourceSpec componentInfo; ResourceSpec componentIcon; };Thecomponent
field specifies the resource type and resource ID of the component's executable code. By convention, this field should be set to the valuekAudioCodeType
.
#define kAudioCodeType 'adio' /*audio component code type*/(You can, however, specify some other resource type if you wish.) The resource ID can be any integer greater than or equal to 128. See the following section for further information about this code resource.The
componentName
field specifies the resource type and resource ID of the resource that contains the component's name. Usually the name is contained in a resource of type'STR '
. This string should be as short as possible.The
componentInfo
field specifies the resource type and resource ID of the resource that contains a description of the component. Usually the description is contained in a resource of type'STR '
.The
componentIcon
field specifies the resource type and resource ID of the resource that contains an icon for the component. Usually the icon is contained in a resource of type'ICON'
.The
cd
field of theComponentResource
structure is a component description record, which contains additional information about the component. A component description record is defined by theComponentDescription
data type.
typedef struct { OSType componentType; OSType componentSubType; OSType componentManufacturer; unsigned long componentFlags; unsigned long componentFlagsMask; } ComponentDescription;For audio components, thecomponentType
field must be set to a value recognized by the Sound Manager.
#define kAudioComponentType 'adio' /*audio component*/In addition, thecomponentSubType
field must be set to a value that indicates the type of audio services your component provides. For example, the Apple-supplied audio components have these subtypes:
#define kAwacsPhoneSubType 'hphn' /*AWACS phone*/ #define kAudioVisionSpeakerSubType 'telc' /*AudioVision speaker*/ #define kAudioVisionHeadphoneSubType 'telh' /*AudioVision headphones*/If you write an audio component, you should define some other subtype.
You can assign any value you like to the
- Note
- Apple Computer, Inc., reserves for its own use all types and subtypes composed solely of lowercase letters.
componentManufacturer
field; typically you put the signature of your audio component in this field.The
componentFlags
field of the component description for an audio component contains bit flags that encode information about the component. You can use this field to specify that the Component Manager should send your component thekComponentRegisterSelect
selector.
enum { cmpWantsRegisterMessage = 1L<<31 /*send register request*/ };This bit is useful for audio components, which might need to test for the presence of the appropriate hardware to determine whether to register with the Component Manager. When your component gets thekComponentRegisterSelect
selector at system startup time, it should make sure that all the necessary hardware is available. If it isn't available, your component shouldn't register.You should set the
componentFlagsMask
field to 0.Your audio component is contained in a resource file. You can assign any type you wish to be the file creator, but the type of the file must be
'thng'
. If the audio component contains a'BNDL'
resource, then the file's bundle bit must be set.