Does an audio queue callback function have to be a C style function? Or can it be an objective C style method?
Depends entirely on the API; if the API calls for a function, block or method, that is what you must use.
As long as the callback function type is something like:
void (*hollabackman)(AudioGunk*foo, void*context);
And the API for setting up the callback is something like:
setCallback(hollabackman func, void *context);
Then you can:
- myMethod
{
setCallback(&myCallbackFunc, (void *)self);
}
- (void) hollaedBack: (AudioGunk*) aGunk
{
.....
}
Then:
void myCallbackFunc(AudioGunk *foo, void *context)
{
MyClass *self = (MyClass *) context;
[self hollaedBack: foo];
}
I would suggest that you retain
self when setting up the callback and only balance it with a release
when you tear down the callback.
CoreAudio (including AudioQueueServices) does not have an ObjectiveC interface - pure C is the answer for directly interfacing with CoreAudio.
You could however create some wrapping C-functions calling a singleton ObjectiveC object method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With