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);
}
And in the class initialisation,
if ((chk = jack_set_process_callback(jack_client, ProcessJackCallback,
this)))
{ ... }
And the callback function ...
int AudioOutputJACK::ProcessJackCallback(jack_nframes_t nframes, void* arg)
{
AudioOutputJACK* audJ = static_cast<AudioOutputJACK*>(arg);
// then stuff like ...
size_t bytes_requested = nframes * audJ->jack_frame_bytes;
size_t bytes_read = jack_ringbuffer_read(audJ->ringbuffJ,
(char*)audJ->jack_tfer_buf,
bytes_requested);
etc ...
}
cheers, Cal
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Nov 11 00:15:07 2008
This archive was generated by hypermail 2.1.8 : Tue Nov 11 2008 - 00:15:07 EET