Confusing problem with GetComponentInfo()
Confusing problem with GetComponentInfo()
- Subject: Confusing problem with GetComponentInfo()
- From: "Chris Reed" <email@hidden>
- Date: Fri, 15 Nov 2002 15:27:50 -0600
- Thread-topic: Confusing problem with GetComponentInfo()
Hi everyone...
I'm changing SynthTest to use a pull-down menu listing the components in a hierchical fashion by manufacturer. The selected component is shown by a pair of static text fields (NSTextField). So I'm calling GetComponentInfo() every time a new component is selected, either synth or effect.
Building the menu is trouble free, as is updating the static text fields the first time, regardless of the selected component.
The problem is, for certain components (always the same ones, apparently), GetComponentInfo() does not fill in the name handle if called when the user selects a new component from the menu.
The method that updates the NSTextField objects is listed below. The -synthComponentDescription method returns a ComponentDescription*.
I've verified that the component description returned by -synthComponentDescription is valid, as is theComp filled out by GetComponentInfo(), which btw returns noErr. It just doesn't fill in nameHandle. In fact, if I allocate the handle with any given size, the size is not changed upon return from GetComponentInfo(). Again, this is for only certain components.
The only thing different from how I build the menu is that the component description passed to FindNextComponent() describes a single specific component instead of using wildcard 0 values.
Some of the components that always fail are: AirySynth, the Expert Sleepers PingPongDelay, all of the Elemental Audio components, Airy's Vowler. It almost seems like it's certain manufacturers, but Airy's AUStk works fine.
Again the strange thing is that the very first time this method is called, to fill in the initial values of the NSTextField objects, it works fine even for the components listed above. And of course, GetComponentInfo() works OK when I'm building the menus.
Thanks
-chris
- (void)updateSelectedSynthName
{
Handle nameHandle = NewHandle(0);
Component comp = FindNextComponent(NULL, [self synthComponentDescription]);
ComponentDescription theComp;
OSErr err = GetComponentInfo(comp, &theComp, nameHandle, NULL, NULL);
if (err)
{
NSLog(@"error %d while getting component name", err);
return;
}
if (GetHandleSize(nameHandle) == 0)
{
DisposeHandle(nameHandle);
NSLog(@"component name was empty");
return;
}
HLock(nameHandle);
NSString *compName = [NSString stringWithCString:(*nameHandle)+1 length:GetHandleSize(nameHandle)-1];
HUnlock(nameHandle);
DisposeHandle(nameHandle);
NSArray *nameComponents = [compName componentsSeparatedByString:@": "];
[synthMfgName setStringValue:[nameComponents objectAtIndex:0]];
[synthName setStringValue:[nameComponents objectAtIndex:1]];
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.