Thread: WDL in the wild
View Single Post
Old 11-02-2010, 09:42 PM   #79
sstillwell
Human being with feelings
 
Join Date: Jul 2006
Location: Cowtown
Posts: 1,562
Default

Progress made!

You were exactly right...we have to define the resources to tell OS X that there is 64-bit code to be loaded.

Pardon the code dump...my GIT isn't accessible outside at the moment.

IPlugAU.r
Code:
#include "resource.h"   // This is your plugin's resource.h.
#include <AudioUnit/AudioUnit.r>

#define UseExtendedThingResource 1

#include <CoreServices/CoreServices.r>

// this is a define used to indicate that a component has no static data that would mean 
// that no more than one instance could be open at a time - never been true for AUs
#ifndef cmpThreadSafeOnMac
#define cmpThreadSafeOnMac	0x10000000
#endif

#undef  TARGET_REZ_MAC_PPC
#ifdef ppc_YES
	#define TARGET_REZ_MAC_PPC        1
#else
	#define TARGET_REZ_MAC_PPC        0
#endif

#undef  TARGET_REZ_MAC_X86
#ifdef i386_YES
	#define TARGET_REZ_MAC_X86        1
#else
	#define TARGET_REZ_MAC_X86        0
#endif

#undef  TARGET_REZ_MAC_PPC64
#ifdef ppc64_YES
#define TARGET_REZ_MAC_PPC64        1
#else
#define TARGET_REZ_MAC_PPC64        0
#endif

#undef  TARGET_REZ_MAC_X86_64
#ifdef x86_64_YES
#define TARGET_REZ_MAC_X86_64        1
#else
#define TARGET_REZ_MAC_X86_64        0
#endif

#if TARGET_OS_MAC
// quad fat binaries
  #ifdef TARGET_REZ_MAC_PPC && TARGET_REZ_MAC_X86 && TARGET_REZ_MAC_X86_64 && TARGET_REZ_MAC_PPC64
    #define TARGET_REZ_FAT_COMPONENTS_4	1
    #define Target_PlatformType	 platformPowerPCNativeEntryPoint
    #define Target_SecondPlatformType	platformIA32NativeEntryPoint
    #define Target_ThirdPlatformType	platformX86_64NativeEntryPoint
    #define Target_FourthPlatformType	platformPowerPC64NativeEntryPoint
// dual fat binaries
	#elif TARGET_REZ_MAC_PPC && TARGET_REZ_MAC_X86
		#define TARGET_REZ_FAT_COMPONENTS_2	1
		#define Target_PlatformType			platformPowerPCNativeEntryPoint
		#define Target_SecondPlatformType	platformIA32NativeEntryPoint
// single-architecture binaries
	#elif TARGET_REZ_MAC_X86
		#define Target_PlatformType			platformIA32NativeEntryPoint

  #elif TARGET_REZ_MAC_X86_64
    #define Target_PlatformType			platformX86_64NativeEntryPoint

  #elif TARGET_REZ_MAC_PPC64
    #define Target_PlatformType			platformPowerPC64NativeEntryPoint

  #else
		#define Target_PlatformType			platformPowerPCNativeEntryPoint

	#endif
	#define Target_CodeResType		'dlle'
	#define TARGET_REZ_USE_DLLE		1
#else
	#error get a real platform type
#endif // not TARGET_OS_MAC

#ifndef TARGET_REZ_FAT_COMPONENTS_2
  #define TARGET_REZ_FAT_COMPONENTS_2			0
#endif

#ifndef TARGET_REZ_FAT_COMPONENTS_4
  #define TARGET_REZ_FAT_COMPONENTS_4			0
#endif

// ----------------

//#ifdef _DEBUG
//  #define PLUG_PUBLIC_NAME PLUG_NAME "_DEBUG"
//#else
#define PLUG_PUBLIC_NAME PLUG_NAME
//#endif

#define RES_ID 1000
#define RES_NAME PLUG_MFR ": " PLUG_PUBLIC_NAME

resource 'STR ' (RES_ID, purgeable) {
	RES_NAME
};

resource 'STR ' (RES_ID + 1, purgeable) {
	PLUG_PUBLIC_NAME " AU"
};

resource 'dlle' (RES_ID) {
	PLUG_ENTRY_STR
};

resource 'thng' (RES_ID, RES_NAME) {
#if PLUG_IS_INST
  kAudioUnitType_MusicDevice,
#else
  kAudioUnitType_Effect,
#endif
	PLUG_UNIQUE_ID,
	PLUG_MFR_ID,
	0, 0, 0, 0,								//	no 68K
	'STR ',	RES_ID,
	'STR ',	RES_ID + 1,
	0,	0,			// icon 
	PLUG_VER,
	componentHasMultiplePlatforms | componentDoAutoVersion,
	0,
	{
		cmpThreadSafeOnMac, 
		Target_CodeResType, RES_ID,
		Target_PlatformType,
#if TARGET_REZ_FAT_COMPONENTS_2
		cmpThreadSafeOnMac, 
		Target_CodeResType, RES_ID,
		Target_SecondPlatformType,
#elif TARGET_REZ_FAT_COMPONENTS_4
		cmpThreadSafeOnMac,
		Target_CodeResType, RES_ID,
		Target_SecondPlatformType,
		cmpThreadSafeOnMac,
		Target_CodeResType, RES_ID,
		Target_ThirdPlatformType,
		cmpThreadSafeOnMac,
		Target_CodeResType, RES_ID,
		Target_FourthPlatformType,						
#endif
	}
};

#undef RES_ID
#define RES_ID 2000
#undef RES_NAME
#define RES_NAME PLUG_MFR ": " PLUG_PUBLIC_NAME " Carbon View"

resource 'STR ' (RES_ID, purgeable) {
	RES_NAME
};

resource 'STR ' (RES_ID + 1, purgeable) {
	PLUG_PUBLIC_NAME " AU Carbon View"
};

resource 'dlle' (RES_ID) {
	PLUG_VIEW_ENTRY_STR
};

resource 'thng' (RES_ID, RES_NAME) {
	kAudioUnitCarbonViewComponentType,
	PLUG_UNIQUE_ID,
	PLUG_MFR_ID,
	0, 0, 0, 0,								//	no 68K
	'STR ',	RES_ID,
	'STR ',	RES_ID + 1,
	0,	0,			// icon 
	PLUG_VER,
	componentHasMultiplePlatforms | componentDoAutoVersion,
	0,
	{
		cmpThreadSafeOnMac, 
		Target_CodeResType, RES_ID,
		Target_PlatformType,
#if TARGET_REZ_FAT_COMPONENTS_2
		cmpThreadSafeOnMac, 
		Target_CodeResType, RES_ID,
		Target_SecondPlatformType,
#elif TARGET_REZ_FAT_COMPONENTS_4
		cmpThreadSafeOnMac,
		Target_CodeResType, RES_ID,
		Target_SecondPlatformType,
#endif
	}
};

#undef RES_ID
Note that the CarbonView resources are only defined for PPC and IA32, even when a quad-fat binary is specified...they don't exist on 64-bit. Don't know if that's correct or not, but there y'go.

AULab recognizes the 64-bit plugin when launched in 64-bit mode (if you don't know how that works...do a "Get Info" on the application and uncheck the box "Launch in 32-bit mode", then launch it). It crashes when AudioUnitGetPropertyInfo calls down into the IPlugAUEntry, so there's something else busted...but this is progress!

Crashes thus:

Code:
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000810000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   ...chwa.audiounit.IPlugExample	0x0000000113db1db8 IPlugAU::IPlugAUEntry(ComponentParameters*, void*) + 392
1   ...apple.audio.units.AudioUnit	0x00007fff8115dfbf AudioUnitGetPropertyInfo + 59
2   com.apple.audio.aulab         	0x0000000100002d99 0x100000000 + 11673
3   com.apple.audio.aulab         	0x000000010005002d 0x100000000 + 327725
4   com.apple.audio.aulab         	0x000000010004d928 0x100000000 + 317736
5   com.apple.audio.aulab         	0x000000010004e62e 0x100000000 + 321070
6   com.apple.audio.aulab         	0x000000010004de9d 0x100000000 + 319133
7   com.apple.audio.aulab         	0x000000010003d5d8 0x100000000 + 251352
8   com.apple.audio.aulab         	0x000000010006ebb5 0x100000000 + 453557
9   com.apple.AppKit              	0x00007fff82b40ae9 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1515
10  com.apple.AppKit              	0x00007fff82b3ecd9 loadNib + 226
11  com.apple.AppKit              	0x00007fff82b3e3ec +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 763
12  com.apple.AppKit              	0x00007fff82b3e021 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
13  com.apple.AppKit              	0x00007fff82b3b5a3 NSApplicationMain + 279
14  com.apple.audio.aulab         	0x000000010000147c 0x100000000 + 5244
Scott
__________________
https://www.stillwellaudio.com/
sstillwell is offline   Reply With Quote