• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Building the CarbonView as a separate component?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building the CarbonView as a separate component?


  • Subject: Re: Building the CarbonView as a separate component?
  • From: "B.J. Buchalter" <email@hidden>
  • Date: Wed, 12 May 2010 16:23:54 -0400


On May 12, 2010, at 3:07 PM, tahome izwah wrote:

Sorry, but I honestly wasn't aware of any way to have a 32bit Carbon
UI on a 64bit AU. Now that I think about it some more, it does make a
lot of sense. Would you be willing to share how you solved this?

Sure.

What I did is:

1. I set up the AU to have a CarbonViewComponent thng resource that points to an entry point in the AU executable (I call it CarbonUIViewEntryShim). That is built into the main AU.

2. I made another target for the actual CarbonUI - it is just a carbon loadable bundle. Put all the UI code into that target.

3. Make the main AU target have a direct dependency on the CarbonUI Target (just like you would do with a Cocoa bundle).

4. Make the main AU target copy the built CarbonUI bundle into its resources (just like you would do with a Cocoa bundle).

5. Put this code into your main AU:

extern "C" {
typedef ComponentResult (*ViewEntryPointer)(ComponentParameters *params, void *obj);
};


extern "C" ComponentResult CarbonAUViewEntryShim(ComponentParameters *params, void *obj)
{
ComponentResult result = fnfErr;
// This generic entry point for a CarbonUI Compnent will load the bundle for the cabon
// view and call-thu to the real entry point
static CFBundleRef theUIBundle = NULL;
static ViewEntryPointer theViewEntry;


if (NULL == theViewEntry) {
CFBundleRef bundle = CFBundleGetBundleWithIdentifier ( CFSTR("com.mhlabs.audiounit.myplugin") );

if (bundle == NULL) return fnfErr;

CFURLRef bundleURL = CFBundleCopyResourceURL( bundle,
CFSTR("CarbonUI"),
CFSTR("bundle"),
NULL);

if (bundleURL == NULL) return fnfErr;

theUIBundle = CFBundleCreate(NULL, bundleURL);

if (theUIBundle) {
theViewEntry = (ViewEntryPointer)CFBundleGetFunctionPointerForName(theUIBundle, CFSTR("CarbonAUViewEntry"));
}
}

if (theViewEntry) {
result = theViewEntry(params, obj);
}

return result;
}


This will load the Carbon bundle once for all instances of your plugin. There may be a memory leak of the loaded bundle depending on if your AU is fully unloaded by the host -- I have not checked that far yet.

In the code that is above,

"com.mhlabs.audiounit.myplugin" needs to be replaced with the CFBundleID of your main plugin.

If you name the build product for the Carbon bundle "CarbonUI.bundle" and you name the View Component class "CarbonAUView" then you
don't need to make changes to the other strings. If you name things differently, then you will need to make the appropriate adjustments.


So basically, you are just implementing what the host does for CocoaUIs within the plugin, and you register the CarbonUI through the shim, so your view component gets autoregistered by the Component Manager along with your AU.

Obviously, when running 64-bit, there is no way to actually load the Carbon bundle; it appears that the hosts don't even probe for the CarbonView component when running 64-bit, so all is well.

Best regards,

B.J. Buchalter
Metric Halo
http://www.mhlabs.com
	


_______________________________________________ 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
References: 
 >Building the CarbonView as a separate component? (From: "B.J. Buchalter" <email@hidden>)
 >Re: Building the CarbonView as a separate component? (From: tahome izwah <email@hidden>)
 >Re: Building the CarbonView as a separate component? (From: "B.J. Buchalter" <email@hidden>)
 >Re: Building the CarbonView as a separate component? (From: tahome izwah <email@hidden>)

  • Prev by Date: Re: Polling a Clock
  • Next by Date: Re: Polling a Clock
  • Previous by thread: Re: Building the CarbonView as a separate component?
  • Next by thread: Re: Building the CarbonView as a separate component?
  • Index(es):
    • Date
    • Thread