• 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: MusicSequencerUserCallback - calling objective-c method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MusicSequencerUserCallback - calling objective-c method


  • Subject: Re: MusicSequencerUserCallback - calling objective-c method
  • From: Simone Tellini <email@hidden>
  • Date: Thu, 09 Dec 2010 10:07:37 +0100

Il 09/12/2010 01:21, GW Rodriguez ha scritto:
Simone,

This has been very helpful.  Two questions though, you suggest this line of code:

MusicSequenceSetUserCallback (sequence, MyCallback, myObj);

For the second argument I have to cast it to MusicSequenceUserCallback right?

if the callback has the correct signature and the compiler knows about it, you shouldn't need the cast.

 Also for the third argument when I put myObj (but this is name of the instance of the class I created) I get a fail on the complier that says it was not declared in this scope. 

perhaps you should post your code. From that description, I can only assume that myObj in your case is not a variable holding a reference to the right instance.

Since the set user callback function is within the @implementation section and the callback declaration is outside of the @implementation section, how do I pass the *void inClientData?


it seems to me that there's some confusion here (or I don't know what you mean :). The @implementation section has nothing to do with the C++ code.

Let's assume you have the following structure:

MyObj.h  -> defines your ObjC class
MyObj.mm (or MyObj.m, depending on your preferences/compiler settings) -> contains the implementation of your ObjC class
SomethingElse.cpp -> contains the code that sets up the callback

In the latter, you probably have something like this:

#import "MyObj.h"
//...

void SomethingElse::MyCallback( void *clientData, MusicSequence sequence, MusicTrack track,
                                 MusicTimeStamp eventTime, const MusicEventUserData *eventData,
                                 MusicTimeStamp startSliceBeat, MusicTimeStamp endSliceBeat )
{
 // ...
}

void SomethingElse::SomeMethod()
{
    MyObj    *myObj = [[MyObj alloc] init];

// ...
    MusicSequenceSetUserCallback( sequence, MyCallback, myObj );
// ...

// ...keep a reference to myObj somewhere to release it when done, of course...
}


or even:

void SomethingElse::SomeMethod( MyObj *myObj )
{
// ...
    MusicSequenceSetUserCallback( sequence, MyCallback, myObj );
// ...
}



Btw, the code above assumes that SomethingElse.h contains:

class SomethingElse
{
// ...
private:
    static void MyCallback( void *clientData, MusicSequence sequence, MusicTrack track,
                                 MusicTimeStamp eventTime, const MusicEventUserData *eventData,
                                 MusicTimeStamp startSliceBeat, MusicTimeStamp endSliceBeat );
// ...
}

--
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

References: 
 >RE: MusicSequencerUserCallback - calling objective-c method (From: GW Rodriguez <email@hidden>)

  • Prev by Date: RE: MusicSequencerUserCallback - calling objective-c method
  • Next by Date: Strange silence problem
  • Previous by thread: RE: MusicSequencerUserCallback - calling objective-c method
  • Next by thread: Tearing Down remoteIO unit - PerformThru errors
  • Index(es):
    • Date
    • Thread