Commit 7ca13a6b authored by sletz's avatar sletz
Browse files

rebase from trunk 3528:3550

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@3551 0c269be4-1314-0410-8aa9-9f06e86f4224
parent b4f737eb
......@@ -25,9 +25,31 @@ Paul Davis
Jackdmp changes log
---------------------------
2009-05-18 Stephane Letz <letz@grame.fr>
* Correct wcsript files to create jackdbus only (and not create jackd anymore) when compiled in --dbus mode, add a --classic option. Both options are possible but issue a warning.
2009-05-15 Stephane Letz <letz@grame.fr>
* Move InitFrameTime in JackDriver::Start method.
2009-05-13 Stephane Letz <letz@grame.fr>
* Reworked Torben Hohn fix for server restart issue on Windows.
2009-05-11 Stephane Letz <letz@grame.fr>
* New jack_free function added in jack.h.
* Torben Hohn fix for InitTime and GetMicroSeconds in JackWinTime.c.
2009-05-07 Stephane Letz <letz@grame.fr>
* Cleanup "loopback" stuff in server.
2009-05-06 Stephane Letz <letz@grame.fr>
* Fix transport callback (timebase master, sync) issue when used after jack_activate (RT thread was not running).
* Fix transport callback (timebase master, sync) issue when used after jack_activate (RT thread was not running).
* D-Bus access for jackctl_server_add_slave/jackctl_server_remove_slave API.
2009-05-05 Stephane Letz <letz@grame.fr>
......
......@@ -241,6 +241,7 @@ extern "C"
EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
jack_intclient_t intclient);
EXPORT void jack_free(void* ptr);
#ifdef __cplusplus
}
......@@ -1930,3 +1931,8 @@ jack_get_version_string()
{
return VERSION;
}
EXPORT void jack_free(void* ptr)
{
free(ptr);
}
......@@ -77,10 +77,6 @@ struct jackctl_server
/* int32_t, msecs; if zero, use period size. */
union jackctl_parameter_value client_timeout;
union jackctl_parameter_value default_client_timeout;
/* uint32_t, ports of the loopback driver */
union jackctl_parameter_value loopback_ports;
union jackctl_parameter_value default_loopback_ports;
/* uint32_t, clock source type */
union jackctl_parameter_value clock_source;
......@@ -643,7 +639,7 @@ EXPORT jackctl_server_t * jackctl_server_create()
if (jackctl_add_parameter(
&server_ptr->parameters,
"name",
"server name to use",
"Server name to use.",
"",
JackParamString,
&server_ptr->name,
......@@ -657,7 +653,7 @@ EXPORT jackctl_server_t * jackctl_server_create()
if (jackctl_add_parameter(
&server_ptr->parameters,
"realtime",
"Whether to use realtime mode",
"Whether to use realtime mode.",
"Use realtime scheduling. This is needed for reliable low-latency performance. On most systems, it requires JACK to run with special scheduler and memory allocation privileges, which may be obtained in several ways. On Linux you should use PAM.",
JackParamBool,
&server_ptr->realtime,
......@@ -714,7 +710,7 @@ EXPORT jackctl_server_t * jackctl_server_create()
if (jackctl_add_parameter(
&server_ptr->parameters,
"client-timeout",
"Client timeout limit in milliseconds",
"Client timeout limit in milliseconds.",
"",
JackParamInt,
&server_ptr->client_timeout,
......@@ -724,25 +720,11 @@ EXPORT jackctl_server_t * jackctl_server_create()
goto fail_free_parameters;
}
value.ui = 0;
if (jackctl_add_parameter(
&server_ptr->parameters,
"loopback-ports",
"Number of loopback ports",
"",
JackParamUInt,
&server_ptr->loopback_ports,
&server_ptr->default_loopback_ports,
value) == NULL)
{
goto fail_free_parameters;
}
value.ui = 0;
if (jackctl_add_parameter(
&server_ptr->parameters,
"clock-source",
"Clocksource type : c(ycle) | h(pet) | s(ystem)",
"Clocksource type : c(ycle) | h(pet) | s(ystem).",
"",
JackParamUInt,
&server_ptr->clock_source,
......@@ -756,7 +738,7 @@ EXPORT jackctl_server_t * jackctl_server_create()
if (jackctl_add_parameter(
&server_ptr->parameters,
"replace-registry",
"Replace registry",
"Replace shared memory registry.",
"",
JackParamBool,
&server_ptr->replace_registry,
......@@ -770,7 +752,7 @@ EXPORT jackctl_server_t * jackctl_server_create()
if (jackctl_add_parameter(
&server_ptr->parameters,
"sync",
"Use synchronous mode",
"Use server synchronous mode.",
"",
JackParamBool,
&server_ptr->sync,
......@@ -880,7 +862,6 @@ jackctl_server_start(
server_ptr->client_timeout.i,
server_ptr->realtime.b,
server_ptr->realtime_priority.i,
server_ptr->loopback_ports.ui,
server_ptr->verbose.b,
(jack_timer_type_t)server_ptr->clock_source.ui,
server_ptr->name.str);
......
......@@ -315,6 +315,7 @@ int JackDriver::Write()
int JackDriver::Start()
{
fEngineControl->InitFrameTime();
return 0;
}
......
......@@ -22,7 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackServerGlobals.h"
#include "JackTime.h"
#include "JackFreewheelDriver.h"
#include "JackLoopbackDriver.h"
#include "JackDummyDriver.h"
#include "JackThreadedDriver.h"
#include "JackGlobals.h"
......@@ -39,7 +38,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, long loopback, bool verbose, jack_timer_type_t clock, const char* server_name)
JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, jack_timer_type_t clock, const char* server_name)
{
if (rt) {
jack_info("JACK server starting in realtime mode with priority %ld", priority);
......@@ -54,7 +53,6 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr
fDriverInfo = new JackDriverInfo();
fAudioDriver = NULL;
fFreewheel = false;
fLoopback = loopback;
JackServerGlobals::fInstance = this; // Unique instance
JackServerGlobals::fUserCount = 1; // One user
jack_verbose = verbose;
......@@ -170,7 +168,6 @@ int JackServer::InternalClientLoadAux(JackLoadableInternalClient* client, const
int JackServer::Start()
{
jack_log("JackServer::Start");
fEngineControl->InitFrameTime();
return fAudioDriver->Start();
}
......@@ -203,13 +200,11 @@ int JackServer::SetBufferSize(jack_nframes_t buffer_size)
if (fAudioDriver->SetBufferSize(buffer_size) == 0) {
fFreewheelDriver->SetBufferSize(buffer_size);
fEngine->NotifyBufferSize(buffer_size);
fEngineControl->InitFrameTime();
return fAudioDriver->Start();
} else { // Failure: try to restore current value
jack_error("Cannot SetBufferSize for audio driver, restore current value %ld", current_buffer_size);
fAudioDriver->SetBufferSize(current_buffer_size);
fFreewheelDriver->SetBufferSize(current_buffer_size);
fEngineControl->InitFrameTime();
fAudioDriver->Start();
// SetBufferSize actually failed, so return an error...
return -1;
......@@ -241,7 +236,6 @@ int JackServer::SetFreewheel(bool onoff)
fGraphManager->Restore(&fConnectionState); // Restore previous connection state
fEngine->NotifyFreewheel(onoff);
fFreewheelDriver->SetMaster(false);
fEngineControl->InitFrameTime();
return fAudioDriver->Start();
}
} else {
......@@ -346,7 +340,6 @@ int JackServer::SwitchMaster(jack_driver_desc_t* driver_desc, JSList* driver_par
// Activate master
fAudioDriver = master;
fDriverInfo = info;
fEngineControl->InitFrameTime();
fAudioDriver->Attach();
fAudioDriver->SetMaster(true);
return fAudioDriver->Start();
......
......@@ -57,13 +57,12 @@ class SERVER_EXPORT JackServer
JackConnectionManager fConnectionState;
JackSynchro fSynchroTable[CLIENT_NUM];
bool fFreewheel;
long fLoopback;
int InternalClientLoadAux(JackLoadableInternalClient* client, const char* so_name, const char* client_name, int options, int* int_ref, int* status);
public:
JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, long loopback, bool verbose, jack_timer_type_t clock, const char* server_name);
JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, jack_timer_type_t clock, const char* server_name);
~JackServer();
int Open(jack_driver_desc_t* driver_desc, JSList* driver_params);
......
......@@ -39,12 +39,11 @@ int JackServerGlobals::Start(const char* server_name,
int time_out_ms,
int rt,
int priority,
int loopback,
int verbose,
jack_timer_type_t clock)
{
jack_log("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld ", sync, time_out_ms, rt, priority, verbose);
new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose, clock, server_name); // Will setup fInstance and fUserCount globals
new JackServer(sync, temporary, time_out_ms, rt, priority, verbose, clock, server_name); // Will setup fInstance and fUserCount globals
int res = fInstance->Open(driver_desc, driver_params);
return (res < 0) ? res : fInstance->Start();
}
......@@ -71,7 +70,6 @@ bool JackServerGlobals::Init()
int verbose_aux = 0;
int do_mlock = 1;
unsigned int port_max = 128;
int loopback = 0;
int do_unlock = 0;
int temporary = 0;
......@@ -112,7 +110,6 @@ bool JackServerGlobals::Init()
{ "name", 0, 0, 'n' },
{ "unlock", 0, 0, 'u' },
{ "realtime", 0, 0, 'R' },
{ "loopback", 0, 0, 'L' },
{ "realtime-priority", 1, 0, 'P' },
{ "timeout", 1, 0, 't' },
{ "temporary", 0, 0, 'T' },
......@@ -204,10 +201,6 @@ bool JackServerGlobals::Init()
realtime = 1;
break;
case 'L':
loopback = atoi(optarg);
break;
case 'T':
temporary = 1;
break;
......@@ -296,7 +289,7 @@ bool JackServerGlobals::Init()
free(argv[i]);
}
int res = Start(server_name, driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, loopback, verbose_aux, clock_source);
int res = Start(server_name, driver_desc, driver_params, sync, temporary, client_timeout, realtime, realtime_priority, verbose_aux, clock_source);
if (res < 0) {
jack_error("Cannot start server... exit");
Delete();
......
......@@ -52,7 +52,6 @@ struct SERVER_EXPORT JackServerGlobals
int time_out_ms,
int rt,
int priority,
int loopback,
int verbose,
jack_timer_type_t clock);
static void Stop();
......
......@@ -31,6 +31,7 @@
#include <jack/jslist.h>
#include <jack/systemdeps.h>
#include <stdbool.h>
/** Parameter types, intentionally similar to jack_driver_param_type_t */
typedef enum
......@@ -124,19 +125,6 @@ void
jackctl_server_destroy(
jackctl_server_t * server);
/**
* Call this function to get list of available drivers. List node data
* pointers is a driver object handle (::jackctl_driver_t).
*
* @param server server object handle to get drivers for
*
* @return Single linked list of driver object handles. Must not be
* modified. Always same for same server object.
*/
const JSList *
jackctl_server_get_drivers_list(
jackctl_server_t * server);
/**
* Call this function to start JACK server
*
......@@ -161,6 +149,19 @@ bool
jackctl_server_stop(
jackctl_server_t * server);
/**
* Call this function to get list of available drivers. List node data
* pointers is a driver object handle (::jackctl_driver_t).
*
* @param server server object handle to get drivers for
*
* @return Single linked list of driver object handles. Must not be
* modified. Always same for same server object.
*/
const JSList *
jackctl_server_get_drivers_list(
jackctl_server_t * server);
/**
* Call this function to get list of server parameters. List node data
* pointers is a parameter object handle (::jackctl_parameter_t).
......@@ -174,6 +175,82 @@ const JSList *
jackctl_server_get_parameters(
jackctl_server_t * server);
/**
* Call this function to get list of available internal clients. List node data
* pointers is a internal client object handle (::jackctl_internal_t).
*
* @param server server object handle to get internal clients for
*
* @return Single linked list of internal client object handles. Must not be
* modified. Always same for same server object.
*/
const JSList *
jackctl_server_get_internals_list(
jackctl_server_t * server);
/**
* Call this function to load one internal client.
*
* @param server server object handle
* @param internal internal to use
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_load_internal(
jackctl_server_t * server,
jackctl_internal_t * internal);
/**
* Call this function to unload one internal client.
*
* @param server server object handle
* @param internal internal to unload
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_unload_internal(
jackctl_server_t * server,
jackctl_internal_t * internal);
/**
* Call this function to add a slave in the driver slave list.
*
* @param server server object handle
* @param driver driver to add in the driver slave list.
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_add_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to remove a slave from the driver slave list.
*
* @param server server object handle
* @param driver driver to remove from the driver slave list.
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_remove_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to switch master driver.
*
* @param server server object handle
* @param driver driver to switch to
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_switch_master(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to get name of driver.
*
......@@ -199,6 +276,31 @@ const JSList *
jackctl_driver_get_parameters(
jackctl_driver_t * driver);
/**
* Call this function to get name of internal client.
*
* @param internal internal object handle to get name of
*
* @return internal name. Must not be modified. Always same for same
* internal object.
*/
const char *
jackctl_internal_get_name(
jackctl_internal_t * internal);
/**
* Call this function to get list of internal parameters. List node data
* pointers is a parameter object handle (::jackctl_parameter_t).
*
* @param internal internal object handle to get parameters for
*
* @return Single linked list of parameter object handles. Must not be
* modified. Always same for same internal object.
*/
const JSList *
jackctl_internal_get_parameters(
jackctl_internal_t * internal);
/**
* Call this function to get parameter name.
*
......@@ -413,70 +515,6 @@ bool
jackctl_parameter_constraint_is_fake_value(
jackctl_parameter_t * parameter);
/**
* Call this function to get list of available internal clients. List node data
* pointers is a internal client object handle (::jackctl_internal_t).
*
* @param server server object handle to get internal clients for
*
* @return Single linked list of internal client object handles. Must not be
* modified. Always same for same server object.
*/
const JSList *
jackctl_server_get_internals_list(
jackctl_server_t * server);
/**
* Call this function to get name of internal client.
*
* @param internal internal object handle to get name of
*
* @return internal name. Must not be modified. Always same for same
* internal object.
*/
const char *
jackctl_internal_get_name(
jackctl_internal_t * internal);
/**
* Call this function to get list of internal parameters. List node data
* pointers is a parameter object handle (::jackctl_parameter_t).
*
* @param internal internal object handle to get parameters for
*
* @return Single linked list of parameter object handles. Must not be
* modified. Always same for same internal object.
*/
const JSList *
jackctl_internal_get_parameters(
jackctl_internal_t * internal);
/**
* Call this function to load one internal client.
*
* @param server server object handle
* @param internal internal to use
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_load_internal(
jackctl_server_t * server,
jackctl_internal_t * internal);
/**
* Call this function to unload one internal client.
*
* @param server server object handle
* @param internal internal to unload
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_unload_internal(
jackctl_server_t * server,
jackctl_internal_t * internal);
/**
* Call this function to log an error message.
*
......@@ -510,43 +548,6 @@ jack_log(
/* @} */
/**
* Call this function to add a slave in the driver slave list.
*
* @param server server object handle
* @param driver driver to add in the driver slave list.
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_add_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to remove a slave from the driver slave list.
*
* @param server server object handle
* @param driver driver to remove from the driver slave list.
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_remove_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to switch master driver.
*
* @param server server object handle
* @param driver driver to switch to
*
* @return success status: true - success, false - fail
*/
bool
jackctl_server_switch_master(jackctl_server_t * server,
jackctl_driver_t * driver);
#if 0
{ /* Adjust editor indent */
#endif
......
......@@ -1070,6 +1070,16 @@ void jack_set_info_function (void (*func)(const char *));
/*@}*/
/**
* The free function to be used on memory returned by jack_port_get_connections,
* jack_port_get_all_connections and jack_get_ports functions.
* This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
* Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
*
*/
void jack_free(void* ptr);
#ifdef __cplusplus
}
#endif
......
......@@ -391,6 +391,44 @@ fail:
return NULL;
}
bool
jack_controller_add_slave(
struct jack_controller *controller_ptr,
const char * driver_name)
{
jackctl_driver_t *driver;
driver = jack_controller_find_driver(controller_ptr->server, driver_name);
if (driver == NULL)
{
return false;
}
jack_info("driver \"%s\" selected", driver_name);
return jackctl_server_add_slave(controller_ptr->server, driver);
}
bool
jack_controller_remove_slave(
struct jack_controller *controller_ptr,
const char * driver_name)
{
jackctl_driver_t *driver;
driver = jack_controller_find_driver(controller_ptr->server, driver_name);
if (driver == NULL)
{
return false;
}
jack_info("driver \"%s\" selected", driver_name);
return jackctl_server_remove_slave(controller_ptr->server, driver);
}
bool
jack_controller_load_internal(
struct jack_controller *controller_ptr,
......
......@@ -215,6 +215,44 @@ jack_control_run_method(
"jack_controller_load_internal failed for internal (%s)", internal_name);
}
}
else if (strcmp (call->method_name, "AddSlave") == 0)
{
const char *driver_name;
if (!jack_dbus_get_method_args(call, DBUS_TYPE_STRING, &driver_name, DBUS_TYPE_INVALID))
{
/* The method call had invalid arguments meaning that
* get_method_args() has constructed an error for us.
*/
goto exit;
}