I have a class that contains a MusicPlayer ivar and manages all the MusicPlayer functionality. I have properly initialized the player and created my custom callback within the same class and it worked fine.
I wanted the callback function to be in my main class that has an instance of my player class. I created a method to set the callback and to pass the main class:
// MusicSequence seq.
-(void) setCallback: (MusicSequenceUserCallback) callback fromClass: (void*) inClientData {
CheckError(MusicSequenceSetUserCallback(seq, callback, inClientData), "Setting sequence callback failed", kLine);
NSLog(@"set callback done");
}
// MyDelegateClass
// MyMusicPlayer *player;
static void cBackAutomation (void *inClientData,
MusicSequence inSequence,
MusicTrack inTrack,
MusicTimeStamp inEventTime,
const MusicEventUserData *inEventData,
MusicTimeStamp inStartSliceBeat,
MusicTimeStamp inEndSliceBeat)
{
Float64 x = inEventTime*25;
MyDelegateClass *mainClass = inClientData;
Float64 y = [mainClass yValueAt:x];
y *= 2;
NSLog(@"*** y value: %.2f", y);
[mainClass release];
};
@implementation MyDelegateClass
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
player = [MyMusicPlayer new];
[player setCallback:cBackAutomation fromClass:self];
}
Now when I start the player with MusicPlayerStart(player) I get an error: GW_Proj11.2(998,0x10da7b000) malloc: *** auto malloc[998]: error: GC operation on unregistered thread. Thread registered implicitly. Break on auto_zone_thread_registration_error() to debug.
Any ideas as to what's happening and/or how I can fix this? The program seems to run without an issue but apparently there is a problem.
Thanks in advance.
--
GW Rodriguez