Hi Stéphane,
Post by Stéphane LetzPost by Juan-Pablo CaceresHello Stéphane,
Post by Stéphane LetzPost by Fernando Lopez-LezcanoPost by Stéphane LetzPost by Juan-Pablo CaceresHello all,
I am working on an applications that generates a lot of Jack
clients in jackdmp. When I tested and dynamically create these
Cannot open JackTrip-60 client
jack_client_open() failed, status = 0x21
Is the number 61 hardcoded somewhere?
64 is the current upper limit yes (= 3 drivers + 61 clients)
Is this something that can be changed at compile time?
rev 2957 now allows that : use --clients=num and --ports=num to
configure max client and ports numbers.
Just out curiosity: what use case needs such a high number of jack clients?
I am building a server in which clients connect and listen to a
physical model (a ping sound) that tells them what's the quality of
the connection. We'll also going to use this server to connect several
machines around the world at the same time.
The server works by dynamically sending each new client (when a
connection is requested) to a Thread Pool. Each connection is a new
Jack Client. We're scaling up this to the hundreds, that's why I
needed more than 61 separate clients at the same time. This will run
on a 16 core machine.
Are those client allocated in the same process?
Don't forget also that each clients consume "some" ressources, like 2
threads for each client. What is this Thread Pool used for? Are you sure
this design is the best one?
No, each clients has an independent process callback. That was something
that was actually hard to implement, and I came with a solution before
being in this list, so here it is. The trick in on the
wrapperProcessCallback function.
The thread pool is used to send the whole class, which in itself
consists on several threads (jack threads + network threads). I am not
sure if it's the best design, but it's the best I could come with ;) Do
you have any suggestions?
//=================================================================================
/** \brief JACK process callback
*
* This is the function to be called to process audio. This function is
* of the type JackProcessCallback, which is defined as:\n
* <tt>typedef int(* JackProcessCallback)(jack_nframes_t nframes,
void *arg)</tt>
* \n
* See
*
http://jackaudio.org/files/docs/html/types_8h.html#4923142208a8e7dacf00ca7a10681d2b
* for more details
*/
int processCallback(jack_nframes_t nframes);
/** \brief Wrapper to cast the member processCallback to a static
function pointer
* that can be used with <tt>jack_set_process_callback</tt>
*
* <tt>jack_set_process_callback</tt> needs a static member function
pointer. A normal
* member function won't work because a <b><i>this</i></b> pointer is
passed under the scenes.
* That's why we
* need to cast the member funcion processCallback to the static function
* wrapperProcessCallback. The callback is then set as:\n
* <tt>jack_set_process_callback(mClient,
JackAudioInterface::wrapperProcessCallback,
* this)</tt>
*/
// reference : http://article.gmane.org/gmane.comp.audio.jackit/12873
static int wrapperProcessCallback(jack_nframes_t nframes, void *arg)
{
return static_cast<JackAudioInterface*>(arg)->processCallback(nframes);
}
/** \brief Set the process callback of the member function
processCallback.
* This process will be called by the JACK server whenever there is
work to be done.
* \return 0 on success, otherwise a non-zero error code,
* causing JACK to remove that client from the process() graph.
*/
int setProcessCallback()
{
std::cout << "Setting JACK Process Callback..." << std::endl;
if ( int code =
jack_set_process_callback(mClient,
JackAudioInterface::wrapperProcessCallback, this)
)
{
std::cerr << "Could not set the process callback" << std::endl;
return(code);
}
std::cout << "SUCCESS" << std::endl;
std::cout << gPrintSeparator << std::endl;
return(0);
}