[LAD] xrun callback

2014-09-03 Thread Raphaël BOLLEN

Hello,

I'm trying to use jack_set_xrun_callback to be notified in my application of 
eventual xrun.

in the documentation of the function I see a note: that 'this function cannot be called while the 
client is activated'.


Does it mean that my client must call jack_set_xrun_callback before being activated or that the 
callback cannot be called while client is activated? If it's the later than should I use another 
client that will stay not activated as parameter jack_client_t


It says return 0 on success. Does it mean the callback must succeed doing something or can it just 
increase some counter and return 0. What would be the consequences of a non-zero error code? Would 
jack stop?


Currently I'm registering the callback and then activate and use the client. I'm not sure if I get 
an xrun that does crash my application of if something wrong in the application makes it crash and 
trigger an xrun... Chicken and egg problem.



Is there another way?

Thanks

--
Raphaël.


for reference: from jack.h

 /**
 * Tell the JACK server to call @a xrun_callback whenever there is a
 * xrun, passing @a arg as a parameter.
 *
 * All "notification events" are received in a seperated non RT thread,
 * the code in the supplied function does not need to be
 * suitable for real-time execution.
 *
 * NOTE: this function cannot be called while the client is activated
 * (after jack_activate has been called.)
 *
 * @return 0 on success, otherwise a non-zero error code
 */
int jack_set_xrun_callback (jack_client_t *client,
JackXRunCallback xrun_callback, void *arg) 
JACK_OPTIONAL_WEAK_EXPORT;
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


[LAD] xrun callback

2014-09-04 Thread Raphaël BOLLEN

On 09/03/2014 04:04 PM, Raphaël  BOLLEN wrote:

Hello,

I'm trying to use jack_set_xrun_callback to be notified in my
application of eventual xrun.

in the documentation of the function I see a note: that 'this function
cannot be called while the client is activated'.

Does it mean that my client must call jack_set_xrun_callback before
being activated


Yes. First set the callback, and only later call jack_activate().


Two tiny jack clients which may come in handy:

 * jackxrun: report x-runs on the command line
 * busyjack: create artificial load

http://gareus.org/gitweb/?p=jackfreqd.git;a=tree;f=tools;
gcc -o jackxrun jackxrun.c -ljack
gcc -o busyjack busyjack.c -ljack

./jackxrun # reports xruns in the terminal
./busyjack 90 # will ramp things up to 90% DSP load (default is 50)

It can be used to create x-runs, yet it's not the same as a x-run from hw.

[..]

It says return 0 on success. Does it mean the callback must succeed.


Your callback function must return 0.

Cheers!
robin


Thanks Robin for your explanations and tools.

I think the x-runs (one every few hours) I get are due to hardware because jack_cpu_load is < 5% and 
system load average < 0.2 all periods. The problem is that those xruns make the process thread jump 
to 100% cpu and the process disappears from QJackctl, although jack and other clients still run 
normally. The code also runs fine on another computer.


I'm currently testing with jack priority raised from 40 to 70 to be above irq threads. I did not yet 
have an xrun in this config but It's a bit early to conclude.


I will also try busyjack.


Best regards

--
Raphaël.
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] xrun callback

2014-09-03 Thread Robin Gareus
On 09/03/2014 04:04 PM, Raphaël  BOLLEN wrote:
> Hello,
> 
> I'm trying to use jack_set_xrun_callback to be notified in my
> application of eventual xrun.
> 
> in the documentation of the function I see a note: that 'this function
> cannot be called while the client is activated'.
> 
> Does it mean that my client must call jack_set_xrun_callback before
> being activated 

Yes. First set the callback, and only later call jack_activate().


Two tiny jack clients which may come in handy:

 * jackxrun: report x-runs on the command line
 * busyjack: create artificial load

http://gareus.org/gitweb/?p=jackfreqd.git;a=tree;f=tools;
gcc -o jackxrun jackxrun.c -ljack
gcc -o busyjack busyjack.c -ljack

./jackxrun # reports xruns in the terminal
./busyjack 90 # will ramp things up to 90% DSP load (default is 50)

It can be used to create x-runs, yet it's not the same as a x-run from hw.

[..]
> It says return 0 on success. Does it mean the callback must succeed.

Your callback function must return 0.

Cheers!
robin
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev