-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExampleComponent.m
More file actions
59 lines (46 loc) · 1.36 KB
/
ExampleComponent.m
File metadata and controls
59 lines (46 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// ExampleComponent.m
// AudioUnitExample
//
// Created by Lucius Kwok on 11/28/10.
// Copyright 2010 Felt Tip Inc. All rights reserved.
//
#import "ExampleComponent.h"
@implementation ExampleComponent
+ (NSArray *)availableComponentsOfType:(OSType)componentType {
NSMutableArray *array = [NSMutableArray array];
ComponentDescription found;
ComponentDescription desc;
memset(&desc, 0, sizeof(desc));
desc.componentType = componentType;
Component aComponent = FindNextComponent (NULL, &desc);
while (aComponent != NULL) {
GetComponentInfo (aComponent, &found, nil, nil, nil);
ExampleComponent *exampleComponent = [[[ExampleComponent alloc] initWithComponent:aComponent] autorelease];
[array addObject:exampleComponent];
aComponent = FindNextComponent (aComponent, &desc);
}
return array;
}
- (id)initWithComponent:(Component)aComponent {
self = [super init];
if (self) {
component = aComponent;
}
return self;
}
- (NSString *)name {
ComponentDescription desc;
Handle nameH = NewHandle (0);
GetComponentInfo (component, &desc, nameH, nil, nil);
HLock (nameH);
NSString *name = [[NSString alloc] initWithCString:(*nameH)+1 length:GetHandleSize(nameH)-1];
DisposeHandle (nameH);
return name;
}
- (ComponentDescription)componentDescription {
ComponentDescription desc;
GetComponentInfo (component, &desc, nil, nil, nil);
return desc;
}
@end