• 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
CoreMIDI wrap from carbon [slightly OT]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreMIDI wrap from carbon [slightly OT]


  • Subject: CoreMIDI wrap from carbon [slightly OT]
  • From: email@hidden
  • Date: Mon, 30 Dec 2002 17:31:56 +0100

Hi list,

I have a carbon app from which I want to had CoreMIDI features.
- first I have made a test app in mach-o, which worked great
- then in the carbon app, I declare fake struct (copied from MidiServices.h) and fake functions
- then I glue my func with the loading bundle functions

Everything worked great at that stage but in MIDIInputPortCreate, I have to pass my midi proc, which i declare as static of course, but it appears that when it is called, the proc that is passed (through register r5) is not the address of the proc but a pointer on the address of that proc, so I'm obliged to do some *very* ugly reinterpret_cast to dereference the pointer to the adress of that proc... well i said that it was ugly :(

as in MidiServices.h, I declare in my .h :
typedef void (*MIDIReadProc) (const MIDIPacketList * pktlist, void * readProcRefCon, void * srcConnRefCon);

typedef OSStatus (*MIDIInputPortCreate) (MIDIClientRef client, CFStringRef portName, MIDIReadProc readProc, void * refCon, MIDIPortRef * outPort);

static void midi_proc (const MIDIPacketList * midi_packet_list, void * user_data, void * conn_user_data);

and then in my .cpp :
MIDIReadProc midi_read_proc_glue = reinterpret_cast <MIDIReadProc> (
*reinterpret_cast <int *> (midi_proc)
);
MIDIPortRef midi_in_port = 0;
err = (*MIDIInputPortCreate_glue) (
midi_client_ref,
CFSTR ("Input port"),
midi_read_proc_glue,
reinterpret_cast <void *> (this),
&midi_in_port
);

It works in fact, but I don't understand why, and that's too ugly.
I'm sure that it have to do with the way I do the typedef, but I can't see where.

Could someone see from where it comes ?

Thanks,

Raphael
_______________________________________________
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.

  • Prev by Date: Re: [slightly OT] Emagic EMI 2|6 problem fixed
  • Next by Date: Re: multiple track synthesizer problem
  • Previous by thread: Re: [slightly OT] Emagic EMI 2|6 problem fixed
  • Next by thread: AudioStream format problem
  • Index(es):
    • Date
    • Thread