[fpc-pascal] Carbon: i386 and PPC API differences

EarMaster - Bent Olsen bent at earmaster.com
Mon Sep 29 16:04:21 CEST 2008

Hi all,

I use Xcode to find samples of codes and try to make it work on FPC/Lazarus.
One example opens an AUGraph and send MIDI messages - a small sample. It
calls AUGraphNewNode which returns a node from 1 to n, and it works
perfectly in FPC on Carbon/i386, and of course for Xcode on the same

The same code works fine in Xcode on Carbon/PowerPC, but does not return any
nodes in FPC on Carbon/PowerPC.

I've just started on working with PowerPC, so I thought I'm obviously is
missing out something vital, perhaps with the record definition used by

I've learned about SetExceptionMask and floating points today when using
PowerPC, so maybe I need to handle the records differently also? I know
about little and big endian, but this shouldn't be necessary?

Or perhaps I should define the external call differently on PowerPC?

I've include code snips below, and any hints will be much appreciated.
TIA, and best regards,

// -------- Code snips

// Pascal
  ComponentDescription = record
    componentType: OSType;
    componentSubType: OSType;
    componentManufacturer: OSType;
    componentFlags: UInt32;
    componentFlagMask: UInt32;

function AUGraphNewNode(inGraph: AUGraph; const inDescription:
  inClassDataSize: LongWord; inClassData : Pointer; var outNode : AUNode):
  external name '_AUGraphNewNode'; mwpascal; //

  _Graph: AUGraph;
  _CD: ComponentDescription;
  _Node: AUNode;

  _CD.componentType := kAudioUnitComponentType;
  _CD.componentSubType := kAudioUnitSubType_MusicDevice;
  _CD.componentManufacturer := kAudioUnitID_DLSSynth;
  _CD.componentFlags := 0;
  _CD.componentFlagsMask := 0;
  AUGraphNewNode(_Graph, _CD, 0, nil, _Node); // Node returns zero, but no

// C++
struct ComponentDescription {
  OSType              componentType;          /* A unique 4-byte code
indentifying the command set */
  OSType              componentSubType;       /* Particular flavor of this
instance */
  OSType              componentManufacturer;  /* Vendor indentification */
  unsigned long       componentFlags;         /* 8 each for
Component,Type,SubType,Manuf/revision */
  unsigned long       componentFlagsMask;     /* Mask for specifying which
flags to consider in search, zero during registration */

extern OSStatus AUGraphNewNode(AUGraph inGraph, const ComponentDescription
  UInt32 inClassDataSize, const void *inClassData, AUNode *outNode)

  AUGraph _Graph;
  ComponentDescription _CD;
  AUNode _Node;

  _CD.componentType = kAudioUnitComponentType;
  _CD.componentSubType = kAudioUnitSubType_MusicDevice;
  _CD.componentManufacturer = kAudioUnitID_DLSSynth;
  _CD.componentFlags = 0;
  _CD.componentFlagsMask = 0;
  AUGraphNewNode(_Graph, &_CD, 0, NULL, &_Node); /* Node returns 1

More information about the fpc-pascal mailing list