Browse Source

Use of placement new for dynamic port allocation is possibly not safe... so avoid that until a definitive answer is found.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2285 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
536c0b5476
11 changed files with 36 additions and 36 deletions
  1. +5
    -0
      ChangeLog
  2. +3
    -3
      common/JackAudioDriver.h
  3. +1
    -1
      common/JackConnectionManager.cpp
  4. +2
    -2
      common/JackConnectionManager.h
  5. +2
    -1
      common/JackConstants.h
  6. +3
    -3
      common/JackEngine.cpp
  7. +8
    -8
      common/JackGraphManager.cpp
  8. +1
    -1
      common/JackGraphManager.h
  9. +8
    -1
      common/JackPort.cpp
  10. +1
    -5
      common/JackServer.cpp
  11. +2
    -11
      common/Jackdmp.cpp

+ 5
- 0
ChangeLog View File

@@ -20,6 +20,11 @@ Fernando Lopez-Lezcano
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>

* 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.


+ 3
- 3
common/JackAudioDriver.h View File

@@ -40,9 +40,9 @@ class EXPORT JackAudioDriver : public JackDriver

// static tables since the actual number of ports may be changed by the real driver
// 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;



+ 1
- 1
common/JackConnectionManager.cpp View File

@@ -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
{
assert(connection < CONNECTION_NUM);
assert(connection < CONNECTION_NUM_FOR_PORT);
return (jack_port_id_t)fConnection[port_index].GetItem(connection);
}



+ 2
- 2
common/JackConnectionManager.h View File

@@ -385,12 +385,12 @@ class JackConnectionManager

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 */
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) */
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;



+ 2
- 1
common/JackConstants.h View File

@@ -36,9 +36,10 @@ namespace Jack

#define FIRST_AVAILABLE_PORT 1
#define PORT_NUM 512
#define DRIVER_PORT_NUM 256
#define PORT_NUM_FOR_CLIENT 256

#define CONNECTION_NUM 256
#define CONNECTION_NUM_FOR_PORT 256

#define CLIENT_NUM 64



+ 3
- 3
common/JackEngine.cpp View File

@@ -738,18 +738,18 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds

if (dst == ALL_PORTS) {

jack_int_t connections[CONNECTION_NUM];
jack_int_t connections[CONNECTION_NUM_FOR_PORT];
fGraphManager->GetConnections(src, connections);

// Notifications
JackPort* port = fGraphManager->GetPort(src);
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]);
NotifyPortConnect(src, connections[i], false);
}
} 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);
NotifyPortConnect(connections[i], src, false);
}


+ 8
- 8
common/JackGraphManager.cpp View File

@@ -174,11 +174,11 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff
} else { // Multiple connections

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;
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);
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);
if ((port->fFlags & JackPortIsOutput) == 0) { // ?? Taken from jack, why not (port->fFlags & JackPortIsInput) ?
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 !!!
RequestMonitor(src_index, onoff);
}
@@ -228,7 +228,7 @@ jack_nframes_t JackGraphManager::ComputeTotalLatencyAux(jack_port_id_t port_inde
if (hop_count > 8)
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) {
AssertPort(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();
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();
}

@@ -675,9 +675,9 @@ void JackGraphManager::GetConnectionsAux(JackConnectionManager* manager, const c
int i;
// 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);
res[i] = port->fName;
}
@@ -694,7 +694,7 @@ void JackGraphManager::GetConnectionsAux(JackConnectionManager* manager, const c
// Client
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;

do {


+ 1
- 1
common/JackGraphManager.h View File

@@ -39,8 +39,8 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio

private:

JackPort fPortArray[];
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);
void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index);


+ 8
- 1
common/JackPort.cpp View File

@@ -29,7 +29,14 @@ namespace Jack
{

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()


+ 1
- 5
common/JackServer.cpp View File

@@ -47,11 +47,7 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr
JackGlobals::InitServer();
for (int i = 0; i < CLIENT_NUM; i++)
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);
fEngine = new JackLockedEngine(new JackEngine(fGraphManager, fSynchroTable, fEngineControl));
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver("freewheel", fEngine, fSynchroTable));


+ 2
- 11
common/Jackdmp.cpp View File

@@ -46,7 +46,6 @@ static JackServer* fServer;
static char* server_name = NULL;
static int realtime_priority = 10;
static int do_mlock = 1;
static unsigned int port_max = 128;
static int realtime = 0;
static int loopback = 0;
static int temporary = 0;
@@ -74,11 +73,8 @@ static void usage(FILE* file)
fprintf(file, "\n"
"usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
" [ --name OR -n server-name ]\n"
// " [ --no-mlock OR -m ]\n"
// " [ --unlock OR -u ]\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"
" [ --verbose OR -v ]\n"
" [ --replace-registry OR -r ]\n"
" [ --silent OR -s ]\n"
@@ -145,10 +141,9 @@ int main(int argc, char* argv[])
int waiting;

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[] = {
{ "driver", 1, 0, 'd'
},
{ "driver", 1, 0, 'd'},
{ "verbose", 0, 0, 'v' },
{ "help", 0, 0, 'h' },
{ "port-max", 1, 0, 'p' },
@@ -209,10 +204,6 @@ int main(int argc, char* argv[])
do_mlock = 0;
break;

case 'p':
port_max = (unsigned int)atol(optarg);
break;

case 'P':
realtime_priority = atoi(optarg);
break;


Loading…
Cancel
Save