Does an audio queue callback function have to be a C style function? Or can it be an objective C style method?
Asked
Active
Viewed 547 times
2 Answers
7
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.

Carl Norum
- 219,201
- 40
- 422
- 469

bbum
- 162,346
- 23
- 271
- 359
1
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.

Till
- 27,559
- 13
- 88
- 122