Problem in xcode AU with Cocoa View template?
Problem in xcode AU with Cocoa View template?
- Subject: Problem in xcode AU with Cocoa View template?
- From: Andreas Tell <email@hidden>
- Date: Thu, 9 Oct 2008 16:14:01 +0200
Dear experts,
I'm relataively new to the Audio Unit API and just recently finished my first plugin. I started with the Cocoa View Audio Unit template provided by xcode 3.0. The resulting plugin worked well apart from one problem: If you create several instances of a plugin (not only the view) the Cocoa views of the different instances would start to synchronise so that a parameter change in one UI affects one of the other UIs. After a long debugging session focusing on the code that I wrote I stumbled over the mechanism for listener registration that the Apple template uses:
In line #51 of *_CocoaView.m of a freshly create cocoa view AU template you find the following code:
AudioUnitParameter parameter[] = { { 0, kParam_One, kAudioUnitScope_Global, 0 } };
This mutable global variable is intended to store the structure for the listener communication. Later in line #101 the registration of the listeners writes the view instance's audio unit reference to the first field of each array element:
parameter[i].mAudioUnit = mAU;
The member mAU obviously differs for each view instance and is written to a global structure that is shared between all instances. Since this value is later refered to when the instances set or get parameters the intended target (the local mAU) happens to be replaced with the global variable content, holding the mAU of the most recent listener registration.
This is clearly not intended behaviour and in fact my plugin was fixed by making the parameter array an instance variable.
My question is, have I been using the template incorrectly or is this really a bug in the template?
Thanks,
Andy
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden