Commit c4fb864e authored by Stephane Letz's avatar Stephane Letz
Browse files

Dynamically scan and print backend and internal names in jackd.

parent 7f09225b
......@@ -88,51 +88,12 @@ static void copyright(FILE* file)
{
fprintf(file, "jackdmp " VERSION "\n"
"Copyright 2001-2005 Paul Davis and others.\n"
"Copyright 2004-2012 Grame.\n"
"Copyright 2004-2013 Grame.\n"
"jackdmp comes with ABSOLUTELY NO WARRANTY\n"
"This is free software, and you are welcome to redistribute it\n"
"under certain conditions; see the file COPYING for details\n");
}
static void usage(FILE* file)
{
fprintf(file, "\n"
"usage: jackdmp [ --no-realtime OR -r ]\n"
" [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
" (the two previous arguments are mutually exclusive. The default is --realtime)\n"
" [ --name OR -n server-name ]\n"
" [ --timeout OR -t client-timeout-in-msecs ]\n"
" [ --loopback OR -L loopback-port-number ]\n"
" [ --port-max OR -p maximum-number-of-ports]\n"
" [ --slave-backend OR -X slave-backend-name ]\n"
" [ --internal-client OR -I internal-client-name ]\n"
" [ --verbose OR -v ]\n"
#ifdef __linux__
" [ --clocksource OR -c [ c(ycle) | h(pet) | s(ystem) ]\n"
#endif
" [ --replace-registry ]\n"
" [ --silent OR -s ]\n"
" [ --sync OR -S ]\n"
" [ --temporary OR -T ]\n"
" [ --version OR -V ]\n"
" -d master-backend-name [ ... master-backend args ... ]\n"
#ifdef __APPLE__
" Available master backends may include: coreaudio, dummy, net or netone.\n\n"
#endif
#ifdef WIN32
" Available master backends may include: portaudio, dummy, net or netone.\n\n"
#endif
#ifdef __linux__
" Available master backends may include: alsa, dummy, freebob, firewire, net or netone.\n\n"
#endif
#if defined(__sun__) || defined(sun)
" Available master backends may include: boomer, oss, dummy or net.\n\n"
#endif
" jackdmp -d master-backend-name --help\n"
" to display options for each master backend\n\n");
}
// To put in the control.h interface ??
static jackctl_driver_t * jackctl_server_get_driver(jackctl_server_t *server, const char *driver_name)
{
const JSList * node_ptr = jackctl_server_get_drivers_list(server);
......@@ -147,6 +108,20 @@ static jackctl_driver_t * jackctl_server_get_driver(jackctl_server_t *server, co
return NULL;
}
static void print_server_drivers(jackctl_server_t *server, FILE* file)
{
const JSList * node_ptr = jackctl_server_get_drivers_list(server);
fprintf(file, "Available backends:\n");
while (node_ptr) {
jackctl_driver_t* driver = (jackctl_driver_t *)node_ptr->data;
fprintf(file, " %s (%s)\n", jackctl_driver_get_name(driver), (jackctl_driver_get_type(driver) == JackMaster) ? "master" : "slave");
node_ptr = jack_slist_next(node_ptr);
}
fprintf(file, "\n");
}
static jackctl_internal_t * jackctl_server_get_internal(jackctl_server_t *server, const char *internal_name)
{
const JSList * node_ptr = jackctl_server_get_internals_list(server);
......@@ -161,6 +136,20 @@ static jackctl_internal_t * jackctl_server_get_internal(jackctl_server_t *server
return NULL;
}
static void print_server_internals(jackctl_server_t *server, FILE* file)
{
const JSList * node_ptr = jackctl_server_get_internals_list(server);
fprintf(file, "Available internals:\n");
while (node_ptr) {
jackctl_internal_t* internal = (jackctl_internal_t *)node_ptr->data;
fprintf(file, " %s\n", jackctl_internal_get_name(internal));
node_ptr = jack_slist_next(node_ptr);
}
fprintf(file, "\n");
}
static jackctl_parameter_t * jackctl_get_parameter(const JSList * parameters_list, const char * parameter_name)
{
while (parameters_list) {
......@@ -173,6 +162,38 @@ static jackctl_parameter_t * jackctl_get_parameter(const JSList * parameters_lis
return NULL;
}
static void usage(FILE* file, jackctl_server_t *server)
{
fprintf(file, "\n"
"usage: jackdmp [ --no-realtime OR -r ]\n"
" [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
" (the two previous arguments are mutually exclusive. The default is --realtime)\n"
" [ --name OR -n server-name ]\n"
" [ --timeout OR -t client-timeout-in-msecs ]\n"
" [ --loopback OR -L loopback-port-number ]\n"
" [ --port-max OR -p maximum-number-of-ports]\n"
" [ --slave-backend OR -X slave-backend-name ]\n"
" [ --internal-client OR -I internal-client-name ]\n"
" [ --verbose OR -v ]\n"
#ifdef __linux__
" [ --clocksource OR -c [ c(ycle) | h(pet) | s(ystem) ]\n"
#endif
" [ --replace-registry ]\n"
" [ --silent OR -s ]\n"
" [ --sync OR -S ]\n"
" [ --temporary OR -T ]\n"
" [ --version OR -V ]\n"
" -d master-backend-name [ ... master-backend args ... ]\n"
" jackdmp -d master-backend-name --help\n"
" to display options for each master backend\n\n");
if (server) {
print_server_drivers(server, file);
print_server_internals(server, file);
}
}
// Prototype to be found in libjackserver
extern "C" void silent_jack_error_callback(const char *desc);
......@@ -270,7 +291,7 @@ int main(int argc, char** argv)
value.ui = JACK_TIMER_SYSTEM_CLOCK;
jackctl_parameter_set_value(param, &value);
} else {
usage(stdout);
usage(stdout, NULL);
goto destroy_server;
}
}
......@@ -379,7 +400,7 @@ int main(int argc, char** argv)
/*fallthru*/
case 'h':
usage(stdout);
usage(stdout, server_ctl);
goto destroy_server;
}
}
......@@ -400,7 +421,7 @@ int main(int argc, char** argv)
}
if (!master_driver_name) {
usage(stderr);
usage(stderr, NULL);
goto destroy_server;
}
......@@ -524,15 +545,17 @@ int main(int argc, char** argv)
// Slave drivers
for (it = slaves_list.begin(); it != slaves_list.end(); it++) {
jackctl_driver_t * slave_driver_ctl = jackctl_server_get_driver(server_ctl, *it);
if (slave_driver_ctl)
if (slave_driver_ctl) {
jackctl_server_remove_slave(server_ctl, slave_driver_ctl);
}
}
// Internal clients
for (it = internals_list.begin(); it != internals_list.end(); it++) {
jackctl_internal_t * internal_driver_ctl = jackctl_server_get_internal(server_ctl, *it);
if (internal_driver_ctl)
if (internal_driver_ctl) {
jackctl_server_unload_internal(server_ctl, internal_driver_ctl);
}
}
jackctl_server_close(server_ctl);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment