[LAD] jack and c++
Paul Davis
paul at linuxaudiosystems.com
Mon Nov 10 09:24:05 UTC 2008
On Mon, 2008-11-10 at 20:10 +1100, cal wrote:
> Malte Steiner wrote:
> > For a new audio application I need to code a JACK client with C++. So
> > far I did it only with C and have a problem with giving the pointer to
> > the callback process function, which is a method now. So what is the
> > best performing solution? Is a delegate function a good idea, being
> > static and triggering the method in the objectinstance?
>
> No idea what the best solution might be, but here's an approach I've used...
>
> class AudioOutputJACK
> {
> public:
> [ ... ]
> private:
> static int ProcessJackCallback(jack_nframes_t nframes, void* arg);
> }
i like to add
static int _process_callback (jack_nframes_t nframes, void*
arg) {
ThisObjectType* foo = (ThisObjectType*) arg;
return foo->process_callback (nframes);
}
int process_callback (jack_nframes_t nframes) {
/* the real thing, as a normal member function */
}
the code is a bit cleaner that way.
More information about the Linux-audio-dev
mailing list