I use The Amazing Audio Engine to control sync playback in an iOS app.
The structure requires that you use the C functions as a callback (playbackTimingReceiver) that is called in the audio stream. Then you need to send the main thread again using the C function (AEAudioControllerSendAsynchronousMessageToMainThread) with which you pass the handler (pageTurnHandler).
I'm not too experienced working with C, but as far as I understand, I pass the pointer in the message that needs to be dereferenced.
What I can achieve successfully with the line:
PlaybackManager* receiver = *((PlaybackManager**)userInfo);
But only if I disable ARC in the project for this file using the -fno-objc-arc flag in the compiled sources in the target project.
To my question, is it possible to achieve this with ARC enabled? If so, what is the correct syntax?
Corresponding code segment:
#pragma mark - Audio Timing Callback -(AEAudioControllerTimingCallback)timingReceiverCallback { return playbackTimingReceiver; } static void playbackTimingReceiver(PlaybackManager* receiver, AEAudioController *audioController, const AudioTimeStamp *time, UInt32 const frames, AEAudioTimingContext context) { receiver->_hostTime = getUptimeInMilliseconds(time->mHostTime); AEAudioControllerSendAsynchronousMessageToMainThread(audioController, pageTurnHandler, &audioController, sizeof(id)); } static void pageTurnHandler(AEAudioController *audioController, void *userInfo, int userInfoLength) { PlaybackManager* receiver = *((PlaybackManager**)userInfo); NSLog(@"Receiver:%@", receiver); }
source share