Commit 4a637d21 authored by sletz's avatar sletz
Browse files

jackctl_server_load_master renamed to jackctl_server_switch_master,...

jackctl_server_load_master renamed to jackctl_server_switch_master, jackctl_server_unload_master is removed.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3518 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 909c1616
......@@ -25,6 +25,10 @@ Paul Davis
Jackdmp changes log
---------------------------
2009-04-21 Stephane Letz <letz@grame.fr>
* jackctl_server_load_master renamed to jackctl_server_switch_master, jackctl_server_unload_master is removed.
2009-04-21 Stephane Letz <letz@grame.fr>
* Add jackctl_server_load_master/jackctl_server_unload_master API.
......
......@@ -1196,20 +1196,19 @@ EXPORT bool jackctl_server_remove_slave(jackctl_server * server_ptr, jackctl_dri
{
if (server_ptr->engine != NULL) {
server_ptr->engine->RemoveSlave(driver_ptr->info);
delete driver_ptr->info;
return true;
} else {
return false;
}
}
EXPORT bool jackctl_server_load_master(jackctl_server * server_ptr, jackctl_driver * driver_ptr)
EXPORT bool jackctl_server_switch_master(jackctl_server * server_ptr, jackctl_driver * driver_ptr)
{
// TODO
return false;
if (server_ptr->engine != NULL) {
return (server_ptr->engine->SwitchMaster(driver_ptr->desc_ptr, driver_ptr->set_parameters) == 0);
} else {
return false;
}
}
EXPORT bool jackctl_server_unload_master(jackctl_server * server_ptr, jackctl_driver * driver_ptr)
{
// TODO
return false;
}
......@@ -227,11 +227,7 @@ EXPORT bool jackctl_server_remove_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
EXPORT bool
jackctl_server_load_master(jackctl_server_t * server,
jackctl_driver_t * driver);
EXPORT bool
jackctl_server_unload_master(jackctl_server_t * server,
jackctl_server_switch_master(jackctl_server_t * server,
jackctl_driver_t * driver);
#if 0
......
......@@ -93,6 +93,7 @@ class SERVER_EXPORT JackDriverInterface
virtual bool GetMaster() = 0;
virtual void AddSlave(JackDriverInterface* slave) = 0;
virtual void RemoveSlave(JackDriverInterface* slave) = 0;
virtual std::list<JackDriverInterface*> GetSlaves() = 0;
virtual int ProcessSlaves() = 0;
virtual bool IsRealTime() const = 0;
......@@ -148,8 +149,13 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
void SetMaster(bool onoff);
bool GetMaster();
void AddSlave(JackDriverInterface* slave);
void RemoveSlave(JackDriverInterface* slave);
std::list<JackDriverInterface*> GetSlaves()
{
return fSlaveList;
}
int ProcessSlaves();
virtual int Open();
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackTime.h"
#include "JackFreewheelDriver.h"
#include "JackLoopbackDriver.h"
#include "JackDummyDriver.h"
#include "JackThreadedDriver.h"
#include "JackGlobals.h"
#include "JackLockedEngine.h"
......@@ -51,6 +52,7 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr
fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver(fEngine, GetSynchroTable()));
fLoopbackDriver = new JackLoopbackDriver(fEngine, GetSynchroTable());
fDriverInfo = new JackDriverInfo();
fAudioDriver = NULL;
fFreewheel = false;
fLoopback = loopback;
......@@ -63,6 +65,7 @@ JackServer::~JackServer()
{
delete fGraphManager;
delete fAudioDriver;
delete fDriverInfo;
delete fFreewheelDriver;
delete fLoopbackDriver;
delete fEngine;
......@@ -84,7 +87,7 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
goto fail_close2;
}
if ((fAudioDriver = fDriverInfo.Open(driver_desc, fEngine, GetSynchroTable(), driver_params)) == NULL) {
if ((fAudioDriver = fDriverInfo->Open(driver_desc, fEngine, GetSynchroTable(), driver_params)) == NULL) {
jack_error("Cannot initialize driver");
goto fail_close3;
}
......@@ -313,23 +316,62 @@ void JackServer::ClientKill(int refnum)
JackDriverInfo* JackServer::AddSlave(jack_driver_desc_t* driver_desc, JSList* driver_params)
{
JackDriverInfo* info = new JackDriverInfo();
JackDriverClientInterface* backend = info->Open(driver_desc, fEngine, GetSynchroTable(), driver_params);
if (backend == NULL) {
JackDriverClientInterface* slave = info->Open(driver_desc, fEngine, GetSynchroTable(), driver_params);
if (slave == NULL) {
delete info;
return NULL;
} else {
backend->Attach();
fAudioDriver->AddSlave(backend);
slave->Attach();
fAudioDriver->AddSlave(slave);
return info;
}
}
void JackServer::RemoveSlave(JackDriverInfo* info)
{
JackDriverClientInterface* backend = info->GetBackend();
fAudioDriver->RemoveSlave(info->GetBackend());
backend->Detach();
backend->Close();
JackDriverClientInterface* slave = info->GetBackend();
fAudioDriver->RemoveSlave(slave);
slave->Detach();
slave->Close();
}
int JackServer::SwitchMaster(jack_driver_desc_t* driver_desc, JSList* driver_params)
{
/// Remove current master
fAudioDriver->Stop();
fAudioDriver->Detach();
fAudioDriver->Close();
// Open new master
JackDriverInfo* info = new JackDriverInfo();
JackDriverClientInterface* master = info->Open(driver_desc, fEngine, GetSynchroTable(), driver_params);
if (master == NULL) {
return -1;
} else {
// Get slaves list
std::list<JackDriverInterface*> slave_list = fAudioDriver->GetSlaves();
std::list<JackDriverInterface*>::const_iterator it;
// Move slaves in new master
for (it = slave_list.begin(); it != slave_list.end(); it++) {
JackDriverInterface* slave = *it;
master->AddSlave(slave);
}
// Delete old master
delete fAudioDriver;
delete fDriverInfo;
// Activate master
fAudioDriver = master;
fDriverInfo = info;
fEngineControl->InitFrameTime();
fAudioDriver->Attach();
fAudioDriver->SetMaster(true);
return fAudioDriver->Start();
}
}
//----------------------
......
......@@ -47,7 +47,7 @@ class SERVER_EXPORT JackServer
private:
JackDriverInfo fDriverInfo;
JackDriverInfo* fDriverInfo;
JackDriverClientInterface* fAudioDriver;
JackDriverClientInterface* fFreewheelDriver;
JackDriverClientInterface* fLoopbackDriver;
......@@ -90,7 +90,8 @@ class SERVER_EXPORT JackServer
// Backend management
JackDriverInfo* AddSlave(jack_driver_desc_t* driver_desc, JSList* driver_params);
void RemoveSlave(JackDriverInfo* info);
int SwitchMaster(jack_driver_desc_t* driver_desc, JSList* driver_params);
// Object access
JackLockedEngine* GetEngine();
JackEngineControl* GetEngineControl();
......
......@@ -132,6 +132,11 @@ int JackThreadedDriver::ProcessSlaves()
return fDriver->ProcessSlaves();
}
std::list<JackDriverInterface*> JackThreadedDriver::GetSlaves()
{
return fDriver->GetSlaves();
}
int JackThreadedDriver::ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2)
{
return fDriver->ClientNotify(refnum, name, notify, sync, value1, value2);
......
......@@ -91,6 +91,7 @@ class SERVER_EXPORT JackThreadedDriver : public JackDriverClientInterface, publi
virtual bool GetMaster();
virtual void AddSlave(JackDriverInterface* slave);
virtual void RemoveSlave(JackDriverInterface* slave);
virtual std::list<JackDriverInterface*> GetSlaves();
virtual int ProcessSlaves();
virtual int ClientNotify(int refnum, const char* name, int notify, int sync, int value1, int value2);
......
......@@ -519,11 +519,7 @@ jackctl_server_remove_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
bool
jackctl_server_load_master(jackctl_server_t * server,
jackctl_driver_t * driver);
bool
jackctl_server_unload_master(jackctl_server_t * server,
jackctl_server_switch_master(jackctl_server_t * server,
jackctl_driver_t * driver);
......
......@@ -131,6 +131,7 @@ def build(bld):
'JackNetTool.cpp',
'JackNetInterface.cpp',
'JackArgParser.cpp',
'JackDummyDriver.cpp',
]
if bld.env['IS_LINUX']:
......
......@@ -53,6 +53,24 @@ static jackctl_internal_t * jackctl_server_get_internal(jackctl_server_t *server
return NULL;
}
static jackctl_parameter_t *
jackctl_get_parameter(
const JSList * parameters_list,
const char * parameter_name)
{
while (parameters_list)
{
if (strcmp(jackctl_parameter_get_name((jackctl_parameter_t *)parameters_list->data), parameter_name) == 0)
{
return (jackctl_parameter_t *)parameters_list->data;
}
parameters_list = jack_slist_next(parameters_list);
}
return NULL;
}
static void print_value(union jackctl_parameter_value value, jackctl_param_type_t type)
{
switch (type) {
......@@ -152,6 +170,16 @@ int main(int argc, char *argv[])
server = jackctl_server_create();
parameters = jackctl_server_get_parameters(server);
/*
jackctl_parameter_t* param;
union jackctl_parameter_value value;
param = jackctl_get_parameter(parameters, "verbose");
if (param != NULL) {
value.b = true;
jackctl_parameter_set_value(param, &value);
}
*/
printf("\n========================== \n");
printf("List of server parameters \n");
printf("========================== \n");
......@@ -182,7 +210,24 @@ int main(int argc, char *argv[])
jackctl_server_start(server, jackctl_server_get_driver(server, driver_name));
jackctl_server_load_internal(server, jackctl_server_get_internal(server, client_name));
/*
// Switch master test
jackctl_driver_t* master;
usleep(5000000);
printf("jackctl_server_load_master\n");
master = jackctl_server_get_driver(server, "coreaudio");
jackctl_server_switch_master(server, master);
usleep(5000000);
printf("jackctl_server_load_master\n");
master = jackctl_server_get_driver(server, "dummy");
jackctl_server_switch_master(server, master);
*/
signals = jackctl_setup_signals(0);
jackctl_wait_signals(signals);
......
......@@ -42,7 +42,7 @@ rpc_type server_rpc_jack_client_check(mach_port_t private_port, client_name_t na
rpc_type server_rpc_jack_client_open(mach_port_t server_port, client_name_t name, int pid, mach_port_t* private_port, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
jack_log("rpc_jack_client_opne name = %s", name);
jack_log("rpc_jack_client_open name = %s", name);
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
assert(channel);
channel->ClientOpen((char*)name, pid, private_port, shared_engine, shared_client, shared_graph, result);
......
......@@ -577,6 +577,8 @@
4BF284190F31B4BC00B05BE3 /* JackArgParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF284170F31B4BC00B05BE3 /* JackArgParser.h */; };
4BF2841A0F31B4BC00B05BE3 /* JackArgParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF284160F31B4BC00B05BE3 /* JackArgParser.cpp */; };
4BF2841B0F31B4BC00B05BE3 /* JackArgParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF284170F31B4BC00B05BE3 /* JackArgParser.h */; };
4BF2F4210F9F4DA300B3FFAD /* JackDummyDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3988908B3CF6C00B6F371 /* JackDummyDriver.cpp */; };
4BF2F4220F9F4DA700B3FFAD /* JackDummyDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3988908B3CF6C00B6F371 /* JackDummyDriver.cpp */; };
4BF339160F8B86DC0080FB5B /* JackCoreMidiDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF339140F8B86DC0080FB5B /* JackCoreMidiDriver.h */; };
4BF339170F8B86DC0080FB5B /* JackCoreMidiDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF339150F8B86DC0080FB5B /* JackCoreMidiDriver.cpp */; };
4BF339180F8B86DC0080FB5B /* JackCoreMidiDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF339140F8B86DC0080FB5B /* JackCoreMidiDriver.h */; };
......@@ -5475,6 +5477,7 @@
4BECB2FB0F4451C10091B70A /* JackProcessSync.cpp in Sources */,
4BF339190F8B86DC0080FB5B /* JackCoreMidiDriver.cpp in Sources */,
4BF339210F8B873E0080FB5B /* JackMidiDriver.cpp in Sources */,
4BF2F4220F9F4DA700B3FFAD /* JackDummyDriver.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -5855,6 +5858,7 @@
4BBAE4110F42FA6100B8BD3F /* JackEngineProfiling.cpp in Sources */,
4BECB2F50F4451C10091B70A /* JackProcessSync.cpp in Sources */,
4BF339230F8B873E0080FB5B /* JackMidiDriver.cpp in Sources */,
4BF2F4210F9F4DA300B3FFAD /* JackDummyDriver.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
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