Hi,
I'm approaching to D2 with writing a wrapper for the popular JACK2 client library.

I managed the following troubles:
Translated correctly the C callback style into D delegates types with alias.
Managed some segment faluts happened when not using toStringz() with some "strings" Managed the multithreaded model of jack using __gsharde for global variables needed in a callback

Now I'm in trouble again but this time I can't find a solution without some help.

Have a look at this code:

// jack.di
alias int function(jack_nframes_t nframes, void *arg) JackProcessCallback;
int jack_set_process_callback (jack_client_t *client, JackProcessCallback process_callback, void *arg);

//simple_client.d
int
process (jack_nframes_t nframes, void *arg)
{
    stderr.writeln("process() - data:", arg);
    [...]
}

int main()
{
[...]

    paTestData * data_ptr = &data;
    stderr.writeln("main() - data:",data_ptr);
    jack_set_process_callback (client, &process, data_ptr);

[...]
}

Execution gives:
main() - data:6B6AE0
process() - data:80

of course when trying to access the real data casting to its original type I get a segmentation fault.

I think that part of the problem is that the process() callback runs into a separate thread. What should I try?

Thanks,
Marco.

Reply via email to