gtkmm and xruns

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gtkmm and xruns

Nicolau Werneck

hi there...

I'm making this program using gtkmm for a graphical interface, and jack.

Some times I get  an xrun when I do a big modification  to the interface, and I
want to know how to prevent that...

OK, of course there are general things I can do to prevent xruns in general: my
buffer  size was  small for  example.  But  I  want to  know if  there are  any
programming guidelines I should follow.

I  have a  cc  file with  a  window class,  and its  contructor  does the  jack
initialization, and  sets the process callback. This  process callback function
is declared on a separate file, but in the end everything is compiled together.

How exactly  does this callback  mechanism work? Would  I benefit if  I somehow
isolate all the jack stuff in a separate thread, for example?

Also, to  pass arguments  to the  process function, I'm  using the  main window
class instead of declaring a specific  stucure.  This is part because I'm lazy,
and part to be  pedantic. :) I'm just not sure if this  would have a bad effect
other then making the compilation of the jack part more complicated, because it
has to know about all that big structure instead of a simple one...


One of the programs I made is quite fun. It's a sinusoidal oscillator, it has a
slide for  frequency and  other for  amplitude.  You can  enter the  values via
spinbuttons too.  You can  also set the limits of the freq  slide via two other
spinbuttons.   The  frequency and  amplitude  are  changed  gradually, with  an
exponential damping, whose  factor is also configured by  another spinbutton. I
would be glad to send it to ayone interested! :)   screenshot attached.


thanks, bye...




--
Nicolau Werneck <[hidden email]>         9F99 25AB E47E 8724 2F71
http://cefala.org/~nwerneck                   EA40 DC23 42CE 6B76 B07F
"Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer."
-- Edsger Dijkstra


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel

shot.png (59K) Download Attachment
signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gtkmm and xruns

lars.luthman (Bugzilla)
On Fri, 2007-07-13 at 02:42 -0300, Nicolau Leal Werneck wrote:

> hi there...
>
> I'm making this program using gtkmm for a graphical interface, and jack.
>
> Some times I get  an xrun when I do a big modification  to the interface, and I
> want to know how to prevent that...
>
> OK, of course there are general things I can do to prevent xruns in general: my
> buffer  size was  small for  example.  But  I  want to  know if  there are  any
> programming guidelines I should follow.
>
> I  have a  cc  file with  a  window class,  and its  contructor  does the  jack
> initialization, and  sets the process callback. This  process callback function
> is declared on a separate file, but in the end everything is compiled together.
>
> How exactly  does this callback  mechanism work? Would  I benefit if  I somehow
> isolate all the jack stuff in a separate thread, for example?
It is already isolated. The process() callback is called from a thread created
by the JACK library. If you are running jackd with the -R option this thread
will get FIFO scheduling and will always be prioritised over the GUI thread.


--ll

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gtkmm and xruns

Florian Paul Schmidt-2
In reply to this post by Nicolau Werneck
On Friday 13 July 2007, Nicolau Leal Werneck wrote:

> hi there...
>
> I'm making this program using gtkmm for a graphical interface, and jack.
>
> Some times I get  an xrun when I do a big modification  to the interface,
> and I want to know how to prevent that...
>
> OK, of course there are general things I can do to prevent xruns in
> general: my buffer  size was  small for  example.  But  I  want to  know if
>  there are  any programming guidelines I should follow.
>
> I  have a  cc  file with  a  window class,  and its  contructor  does the
> jack initialization, and  sets the process callback. This  process callback
> function is declared on a separate file, but in the end everything is
> compiled together.
>
> How exactly  does this callback  mechanism work? Would  I benefit if  I
> somehow isolate all the jack stuff in a separate thread, for example?

Like Lars said, it already is run in a separate thread. Even with realtime
prios if jack runs with RT prio. In your code just make sure, you don't use
any non-rt-safe functions. That includes

- networking
- filesystem access
- locking synchronization

So basically any input/output besides processing the samples you get from jack
is not allowed from the audio callback. This includes any GUI functionality.

This makes communication of the rest of the program with the jack stuff
nontrivial. Show us your code and we can tell you more..

>
> Also, to  pass arguments  to the  process function, I'm  using the  main
> window class instead of declaring a specific  stucure.  This is part
> because I'm lazy, and part to be  pedantic. :) I'm just not sure if this
> would have a bad effect other then making the compilation of the jack part
> more complicated, because it has to know about all that big structure
> instead of a simple one...

You can pass to the callback registration whatever pointer you want.

FLo

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel