[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-audio-dev
Subject:    Re: [linux-audio-dev] Jack API query
From:       Paul Davis <pbd () op ! net>
Date:       2002-05-15 12:37:38
[Download RAW message or body]

>.c and connection.c and (think!) I understand them. I just have a couple of qu
>estions which I hoped somebody could help me with. 

I'd be happy to, but you should know that jack-devel is a better list
to use for this purpose. Sign up at http://sf.net/projects/jackit/

>1. Is the 'port_type' string just an arbitrary string if I am defining my own 
>audio type? (instead of using DEFAULT_AUDIO_TYPE)

Correct. However, at this time, support for memory allocation for
other port types is missing. I may be adding it within the next week.

>2. How do I define my own audio types? For example, I wish to import 16bit ste
>reo PCM data from my CD player in 1024 sample chunks. In this case, do i need 
>to set up 2 ports (one for each audio channel) with a buffer of 2048 bytes eac
>h? If so, how do I tell the jack server to feed me data encoded to 16 bits? an
>d how do I define a port as belonging to a particular audio channel? If not, h
>ow do I define and use a stereo source?

None of the above. If you do something like you're describing, no
other JACK client will be able to talk to you. JACK is predicated on
using a few (preferably just one) formats for audio, and the default
format is a mono stream of 32 bit floating point samples. Without this
kind of convention, we end up with lots of silly data conversion going
on all over the place. How you convert data in some other format to
JACK's is up to you.

You don't allocate port buffers at all. JACK does that for you. You
may need your own internal intermediate buffers for the data
conversion, but that has nothing to do with JACK. In addition, you
don't define how large port buffers are. JACK does that too. When your
process callback is executed, its passed an argument that tells the
client how many samples are available to read/write in its buffers.

Associations between ports and "channels" would be done by naming the
port "Left" and "Right" (for example). 

>3. When is 'process()' called (as set by 'int jack_set_process_callback(...). 
>Is it when the buffer is full? If so, is it controlled by the jack server? Pre
>sumably, the ideal situation is that all processing is done and the program is
> waiting (in a loop?) before the 'process()' function is called, thus allowing
> the program to process the next chunk of data?

JACK calls your process() callback when the time is right, and tells
you how many samples you should work on. The number can be any
positive value between 1 and the most recent blocksize setting, inclusive.
Your process() callback is executed from its own thread, which sleeps
99% of the time that its not calling process(). You have no control
over when process() is called, nor can you assume anything about the
number of samples, or the regularity of being called.

--p
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic