Should the sound queue callback function be a C style function? Or could it be an objective C style method?

Should the sound queue callback function be a C style function? Or could it be an objective C style method?

+4
source share
2 answers

Depends entirely on the API; if the API calls a function, block or method, this is what you should use.

So far, the type of the callback function looks something like this:

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 like to offer you retain self when setting up the callback and balancing it only with release when you cancel the callback.

+7
source

CoreAudio (including AudioQueueServices) does not have an ObjectiveC interface - pure C is the answer for interacting directly with CoreAudio.

However, you could create some packaging C functions that call a single-point ObjectiveC object.

+1
source

Source: https://habr.com/ru/post/1346087/


All Articles