List Info

Thread: Explanations on callback mecanism




Explanations on callback mecanism
user name
2006-02-13 00:22:59
I'm new to Jack and I must admit that I find hard having
some details
about how it's implemented in a program (playing ogg).
I've already
been working with callback functions in some of my programs
for video
analysis but that time with audio, it's different. I took a
look over
the simple_client with the doc but it's just a matter of
copying one
buffer to another without knowing anything about data in it.

What I can understand of the process is basicaly that Jack
is calling
a function with a number of frames to be sent when there's
no other
program using its ressources. So during that period, the
callback
function has to deliver samples until it reaches nframes,
then it save
current position into the source buffer so that it could
start from
that point next time it will be called by jack.

Am I telling you right with that ? Would you have something
to add about that ?


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems?  Stop!  Download the new AJAX search engine
that makes
searching your log files as easy as surfing the  web. 
DOWNLOAD SPLUNK!
http:
//sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#
0486&dat1642
_______________________________________________
Jackit-devel mailing list
Jackit-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jackit-dev
el
Explanations on callback mecanism
user name
2006-02-13 13:06:07
On Sun, 2006-02-12 at 19:22 -0500, Pierre-Luc Bacon wrote:
> I'm new to Jack and I must admit that I find hard
having some details
> about how it's implemented in a program (playing ogg).
I've already
> been working with callback functions in some of my
programs for video
> analysis but that time with audio, it's different. I
took a look over
> the simple_client with the doc but it's just a matter
of copying one
> buffer to another without knowing anything about data
in it.
> 
> What I can understand of the process is basicaly that
Jack is calling
> a function with a number of frames to be sent when
there's no other
> program using its ressources. So during that period,
the callback
> function has to deliver samples until it reaches
nframes, then it save
> current position into the source buffer so that it
could start from
> that point next time it will be called by jack.
> 
> Am I telling you right with that ? Would you have
something to add about that ?

thats largely correct, except for a couple of details:

   * JACK will callback into your program when its
"backend" tells it
that its time to read/write more data. JACK will call each
of its client
programs in order (the new implementation, jackdmp, can
actually call
them in parallel but that is another story).

   * the code that your program executes inside its process
callback
needs to be "Real Time Safe". this means that it
cannot make system
calls, cannot allocate memory, cannot do disk i/o, cannot
block on
mutexes etc. in real life, it is possible to violate this
rule without
noticing the effect immediately. however, it will inevitably
come back
to bite you. the general rule for RT safety is:

	  cycles = A * nframes + B

where cycles is the number of CPU cycles that your process
callback
takes to execute, and A and B are constants.

--p

	



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems?  Stop!  Download the new AJAX search engine
that makes
searching your log files as easy as surfing the  web. 
DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jackit-devel mailing list
Jackit-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jackit-dev
el
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )