Re: MusicSequencerUserCallback - calling objective-c method
Re: MusicSequencerUserCallback - calling objective-c method
- Subject: Re: MusicSequencerUserCallback - calling objective-c method
- From: Simone Tellini <email@hidden>
- Date: Wed, 8 Dec 2010 22:03:46 +0100
Il giorno 08/dic/2010, alle ore 21.57, GW Rodriguez ha scritto:
> So I was putting together a basic app that needs to use the user event, ergo it needs to use the callback function. I would like to have the callback function call a obj-c method, but I cant seem to do this. I even tried changed the file to .mm and all I get are errors.
>
> Can someone bestow their experience and knowledge on my as to how to call a obj-c method in a c++ function?
>
use something like this:
void MyCallback( void *clientData, MusicSequence sequence, MusicTrack track,
MusicTimeStamp eventTime, const MusicEventUserData *eventData,
MusicTimeStamp startSliceBeat, MusicTimeStamp endSliceBeat )
{
MyObjCClass *myObj = reinterpret_cast< MyObjCClass *>( clientData );
const MyEventData *event = reinterpret_cast<const MyEventData *>( eventData );
[myObj doSomethingWithMyEventData: event];
}
Then set it up with:
MusicSequenceSetUserCallback( sequence, MyCallback, myObj );
where myObj is an instance of MyObjCClass
Remember to use -performSelectorOnMainThread:withObject:waitUntilDone: to execute anything that has to do with UI stuff, or that needs to be run in the main thread for any reason, because the callback is executed in a background thread.
--
Simone Tellini
http://www.tellini.org
_______________________________________________
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