git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2285 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
@@ -20,6 +20,11 @@ Fernando Lopez-Lezcano | |||||
Jackdmp changes log | Jackdmp changes log | ||||
--------------------------- | --------------------------- | ||||
2008-05-19 Stephane Letz <letz@grame.fr> | |||||
* Use of placement new for dynamic port allocation is possibly not safe... so avoid that until a definitive answer is found. | |||||
* Cleanup. | |||||
2008-05-16 Stephane Letz <letz@grame.fr> | 2008-05-16 Stephane Letz <letz@grame.fr> | ||||
* Activate now connect to FW driver and start the realtime thread only if clients are actually realtime, that is have setup any of the RT callback. | * Activate now connect to FW driver and start the realtime thread only if clients are actually realtime, that is have setup any of the RT callback. | ||||
@@ -40,9 +40,9 @@ class EXPORT JackAudioDriver : public JackDriver | |||||
// static tables since the actual number of ports may be changed by the real driver | // static tables since the actual number of ports may be changed by the real driver | ||||
// thus dynamic allocation is more difficult to handle | // thus dynamic allocation is more difficult to handle | ||||
jack_port_id_t fCapturePortList[PORT_NUM]; | |||||
jack_port_id_t fPlaybackPortList[PORT_NUM]; | |||||
jack_port_id_t fMonitorPortList[PORT_NUM]; | |||||
jack_port_id_t fCapturePortList[DRIVER_PORT_NUM]; | |||||
jack_port_id_t fPlaybackPortList[DRIVER_PORT_NUM]; | |||||
jack_port_id_t fMonitorPortList[DRIVER_PORT_NUM]; | |||||
bool fWithMonitorPorts; | bool fWithMonitorPorts; | ||||
@@ -136,7 +136,7 @@ jack_int_t JackConnectionManager::Connections(jack_port_id_t port_index) const | |||||
jack_port_id_t JackConnectionManager::GetPort(jack_port_id_t port_index, int connection) const | jack_port_id_t JackConnectionManager::GetPort(jack_port_id_t port_index, int connection) const | ||||
{ | { | ||||
assert(connection < CONNECTION_NUM); | |||||
assert(connection < CONNECTION_NUM_FOR_PORT); | |||||
return (jack_port_id_t)fConnection[port_index].GetItem(connection); | return (jack_port_id_t)fConnection[port_index].GetItem(connection); | ||||
} | } | ||||
@@ -385,12 +385,12 @@ class JackConnectionManager | |||||
private: | private: | ||||
JackFixedArray<CONNECTION_NUM> fConnection[PORT_NUM]; /*! Connection matrix: list of connected ports for a given port: needed to compute Mix buffer */ | |||||
JackFixedArray<CONNECTION_NUM_FOR_PORT> fConnection[PORT_NUM]; /*! Connection matrix: list of connected ports for a given port: needed to compute Mix buffer */ | |||||
JackFixedArray1<PORT_NUM_FOR_CLIENT> fInputPort[CLIENT_NUM]; /*! Table of input port per refnum : to find a refnum for a given port */ | JackFixedArray1<PORT_NUM_FOR_CLIENT> fInputPort[CLIENT_NUM]; /*! Table of input port per refnum : to find a refnum for a given port */ | ||||
JackFixedArray<PORT_NUM_FOR_CLIENT> fOutputPort[CLIENT_NUM]; /*! Table of output port per refnum : to find a refnum for a given port */ | JackFixedArray<PORT_NUM_FOR_CLIENT> fOutputPort[CLIENT_NUM]; /*! Table of output port per refnum : to find a refnum for a given port */ | ||||
JackFixedMatrix<CLIENT_NUM> fConnectionRef; /*! Table of port connections by (refnum , refnum) */ | JackFixedMatrix<CLIENT_NUM> fConnectionRef; /*! Table of port connections by (refnum , refnum) */ | ||||
JackActivationCount fInputCounter[CLIENT_NUM]; /*! Activation counter per refnum */ | JackActivationCount fInputCounter[CLIENT_NUM]; /*! Activation counter per refnum */ | ||||
JackLoopFeedback<CONNECTION_NUM> fLoopFeedback; /*! Loop feedback connections */ | |||||
JackLoopFeedback<CONNECTION_NUM_FOR_PORT> fLoopFeedback; /*! Loop feedback connections */ | |||||
bool IsLoopPathAux(int ref1, int ref2) const; | bool IsLoopPathAux(int ref1, int ref2) const; | ||||
@@ -36,9 +36,10 @@ namespace Jack | |||||
#define FIRST_AVAILABLE_PORT 1 | #define FIRST_AVAILABLE_PORT 1 | ||||
#define PORT_NUM 512 | #define PORT_NUM 512 | ||||
#define DRIVER_PORT_NUM 256 | |||||
#define PORT_NUM_FOR_CLIENT 256 | #define PORT_NUM_FOR_CLIENT 256 | ||||
#define CONNECTION_NUM 256 | |||||
#define CONNECTION_NUM_FOR_PORT 256 | |||||
#define CLIENT_NUM 64 | #define CLIENT_NUM 64 | ||||
@@ -738,18 +738,18 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds | |||||
if (dst == ALL_PORTS) { | if (dst == ALL_PORTS) { | ||||
jack_int_t connections[CONNECTION_NUM]; | |||||
jack_int_t connections[CONNECTION_NUM_FOR_PORT]; | |||||
fGraphManager->GetConnections(src, connections); | fGraphManager->GetConnections(src, connections); | ||||
// Notifications | // Notifications | ||||
JackPort* port = fGraphManager->GetPort(src); | JackPort* port = fGraphManager->GetPort(src); | ||||
if (port->GetFlags() & JackPortIsOutput) { | if (port->GetFlags() & JackPortIsOutput) { | ||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { | |||||
jack_log("NotifyPortConnect src = %ld dst = %ld false", src, connections[i]); | jack_log("NotifyPortConnect src = %ld dst = %ld false", src, connections[i]); | ||||
NotifyPortConnect(src, connections[i], false); | NotifyPortConnect(src, connections[i], false); | ||||
} | } | ||||
} else { | } else { | ||||
for (int i = 0; (i < CONNECTION_NUM) && (connections[i] != EMPTY); i++) { | |||||
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && (connections[i] != EMPTY); i++) { | |||||
jack_log("NotifyPortConnect src = %ld dst = %ld false", connections[i], src); | jack_log("NotifyPortConnect src = %ld dst = %ld false", connections[i], src); | ||||
NotifyPortConnect(connections[i], src, false); | NotifyPortConnect(connections[i], src, false); | ||||
} | } | ||||
@@ -174,11 +174,11 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff | |||||
} else { // Multiple connections | } else { // Multiple connections | ||||
const jack_int_t* connections = manager->GetConnections(port_index); | const jack_int_t* connections = manager->GetConnections(port_index); | ||||
void* buffers[CONNECTION_NUM]; | |||||
void* buffers[CONNECTION_NUM_FOR_PORT]; | |||||
jack_port_id_t src_index; | jack_port_id_t src_index; | ||||
int i; | int i; | ||||
for (i = 0; (i < CONNECTION_NUM) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
for (i = 0; (i < CONNECTION_NUM_FOR_PORT) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
AssertPort(src_index); | AssertPort(src_index); | ||||
buffers[i] = GetBuffer(src_index, buffer_size); | buffers[i] = GetBuffer(src_index, buffer_size); | ||||
} | } | ||||
@@ -209,7 +209,7 @@ int JackGraphManager::RequestMonitor(jack_port_id_t port_index, bool onoff) // C | |||||
const jack_int_t* connections = ReadCurrentState()->GetConnections(port_index); | const jack_int_t* connections = ReadCurrentState()->GetConnections(port_index); | ||||
if ((port->fFlags & JackPortIsOutput) == 0) { // ?? Taken from jack, why not (port->fFlags & JackPortIsInput) ? | if ((port->fFlags & JackPortIsOutput) == 0) { // ?? Taken from jack, why not (port->fFlags & JackPortIsInput) ? | ||||
jack_port_id_t src_index; | jack_port_id_t src_index; | ||||
for (int i = 0; (i < CONNECTION_NUM) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && ((src_index = connections[i]) != EMPTY); i++) { | |||||
// XXX much worse things will happen if there is a feedback loop !!! | // XXX much worse things will happen if there is a feedback loop !!! | ||||
RequestMonitor(src_index, onoff); | RequestMonitor(src_index, onoff); | ||||
} | } | ||||
@@ -228,7 +228,7 @@ jack_nframes_t JackGraphManager::ComputeTotalLatencyAux(jack_port_id_t port_inde | |||||
if (hop_count > 8) | if (hop_count > 8) | ||||
return GetPort(port_index)->GetLatency(); | return GetPort(port_index)->GetLatency(); | ||||
for (int i = 0; (i < CONNECTION_NUM) && ((dst_index = connections[i]) != EMPTY); i++) { | |||||
for (int i = 0; (i < CONNECTION_NUM_FOR_PORT) && ((dst_index = connections[i]) != EMPTY); i++) { | |||||
if (src_port_index != dst_index) { | if (src_port_index != dst_index) { | ||||
AssertPort(dst_index); | AssertPort(dst_index); | ||||
JackPort* dst_port = GetPort(dst_index); | JackPort* dst_port = GetPort(dst_index); | ||||
@@ -457,7 +457,7 @@ void JackGraphManager::GetConnections(jack_port_id_t port_index, jack_int_t* res | |||||
{ | { | ||||
JackConnectionManager* manager = WriteNextStateStart(); | JackConnectionManager* manager = WriteNextStateStart(); | ||||
const jack_int_t* connections = manager->GetConnections(port_index); | const jack_int_t* connections = manager->GetConnections(port_index); | ||||
memcpy(res, connections, sizeof(jack_int_t) * CONNECTION_NUM); | |||||
memcpy(res, connections, sizeof(jack_int_t) * CONNECTION_NUM_FOR_PORT); | |||||
WriteNextStateStop(); | WriteNextStateStop(); | ||||
} | } | ||||
@@ -675,9 +675,9 @@ void JackGraphManager::GetConnectionsAux(JackConnectionManager* manager, const c | |||||
int i; | int i; | ||||
// Cleanup connection array | // Cleanup connection array | ||||
memset(res, 0, sizeof(char*) * CONNECTION_NUM); | |||||
memset(res, 0, sizeof(char*) * CONNECTION_NUM_FOR_PORT); | |||||
for (i = 0; (i < CONNECTION_NUM) && ((index = connections[i]) != EMPTY); i++) { | |||||
for (i = 0; (i < PORT_NUM) && ((index = connections[i]) != EMPTY); i++) { | |||||
JackPort* port = GetPort(index); | JackPort* port = GetPort(index); | ||||
res[i] = port->fName; | res[i] = port->fName; | ||||
} | } | ||||
@@ -694,7 +694,7 @@ void JackGraphManager::GetConnectionsAux(JackConnectionManager* manager, const c | |||||
// Client | // Client | ||||
const char** JackGraphManager::GetConnections(jack_port_id_t port_index) | const char** JackGraphManager::GetConnections(jack_port_id_t port_index) | ||||
{ | { | ||||
const char** res = (const char**)malloc(sizeof(char*) * CONNECTION_NUM); | |||||
const char** res = (const char**)malloc(sizeof(char*) * CONNECTION_NUM_FOR_PORT); | |||||
UInt16 cur_index, next_index; | UInt16 cur_index, next_index; | ||||
do { | do { | ||||
@@ -39,8 +39,8 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio | |||||
private: | private: | ||||
JackPort fPortArray[]; | |||||
JackClientTiming fClientTiming[CLIENT_NUM]; | JackClientTiming fClientTiming[CLIENT_NUM]; | ||||
JackPort fPortArray[PORT_NUM]; | |||||
jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags); | ||||
void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index); | ||||
@@ -29,7 +29,14 @@ namespace Jack | |||||
{ | { | ||||
JackPort::JackPort() | JackPort::JackPort() | ||||
: fFlags(JackPortIsInput), fRefNum( -1), fLatency(0), fTotalLatency(0), fMonitorRequests(0), fInUse(false), fTied(NO_PORT) | |||||
: fTypeId(0), | |||||
fFlags(JackPortIsInput), | |||||
fRefNum( -1), | |||||
fLatency(0), | |||||
fTotalLatency(0), | |||||
fMonitorRequests(0), | |||||
fInUse(false), | |||||
fTied(NO_PORT) | |||||
{} | {} | ||||
JackPort::~JackPort() | JackPort::~JackPort() | ||||
@@ -47,11 +47,7 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr | |||||
JackGlobals::InitServer(); | JackGlobals::InitServer(); | ||||
for (int i = 0; i < CLIENT_NUM; i++) | for (int i = 0; i < CLIENT_NUM; i++) | ||||
fSynchroTable[i] = JackGlobals::MakeSynchro(); | fSynchroTable[i] = JackGlobals::MakeSynchro(); | ||||
// Use "placement" new for graph manager | |||||
void* shared_mem = JackShmMem::operator new(PORT_NUM * 1*sizeof(JackPort) + sizeof(JackGraphManager)); | |||||
fGraphManager = new(shared_mem) JackGraphManager(); | |||||
fGraphManager = new JackGraphManager(); | |||||
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, server_name); | fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, server_name); | ||||
fEngine = new JackLockedEngine(new JackEngine(fGraphManager, fSynchroTable, fEngineControl)); | fEngine = new JackLockedEngine(new JackEngine(fGraphManager, fSynchroTable, fEngineControl)); | ||||
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable)); | ||||
@@ -46,7 +46,6 @@ static JackServer* fServer; | |||||
static char* server_name = NULL; | static char* server_name = NULL; | ||||
static int realtime_priority = 10; | static int realtime_priority = 10; | ||||
static int do_mlock = 1; | static int do_mlock = 1; | ||||
static unsigned int port_max = 128; | |||||
static int realtime = 0; | static int realtime = 0; | ||||
static int loopback = 0; | static int loopback = 0; | ||||
static int temporary = 0; | static int temporary = 0; | ||||
@@ -74,11 +73,8 @@ static void usage(FILE* file) | |||||
fprintf(file, "\n" | fprintf(file, "\n" | ||||
"usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n" | "usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n" | ||||
" [ --name OR -n server-name ]\n" | " [ --name OR -n server-name ]\n" | ||||
// " [ --no-mlock OR -m ]\n" | |||||
// " [ --unlock OR -u ]\n" | |||||
" [ --timeout OR -t client-timeout-in-msecs ]\n" | " [ --timeout OR -t client-timeout-in-msecs ]\n" | ||||
" [ --loopback OR -L loopback-port-number ]\n" | " [ --loopback OR -L loopback-port-number ]\n" | ||||
// " [ --port-max OR -p maximum-number-of-ports]\n" | |||||
" [ --verbose OR -v ]\n" | " [ --verbose OR -v ]\n" | ||||
" [ --replace-registry OR -r ]\n" | " [ --replace-registry OR -r ]\n" | ||||
" [ --silent OR -s ]\n" | " [ --silent OR -s ]\n" | ||||
@@ -145,10 +141,9 @@ int main(int argc, char* argv[]) | |||||
int waiting; | int waiting; | ||||
jack_driver_desc_t* driver_desc; | jack_driver_desc_t* driver_desc; | ||||
const char *options = "-ad:P:uvrshVRL:STFl:t:mn:p:"; | |||||
const char *options = "-ad:P:uvrshVRL:STFl:t:mn:"; | |||||
struct option long_options[] = { | struct option long_options[] = { | ||||
{ "driver", 1, 0, 'd' | |||||
}, | |||||
{ "driver", 1, 0, 'd'}, | |||||
{ "verbose", 0, 0, 'v' }, | { "verbose", 0, 0, 'v' }, | ||||
{ "help", 0, 0, 'h' }, | { "help", 0, 0, 'h' }, | ||||
{ "port-max", 1, 0, 'p' }, | { "port-max", 1, 0, 'p' }, | ||||
@@ -209,10 +204,6 @@ int main(int argc, char* argv[]) | |||||
do_mlock = 0; | do_mlock = 0; | ||||
break; | break; | ||||
case 'p': | |||||
port_max = (unsigned int)atol(optarg); | |||||
break; | |||||
case 'P': | case 'P': | ||||
realtime_priority = atoi(optarg); | realtime_priority = atoi(optarg); | ||||
break; | break; | ||||