Browse Source

Correct long standing bug in SyncRecv.

tags/v1.9.10
Stephane Letz 12 years ago
parent
commit
2731c1e850
3 changed files with 52 additions and 36 deletions
  1. +5
    -10
      common/JackNetDriver.cpp
  2. +33
    -15
      common/JackNetInterface.cpp
  3. +14
    -11
      common/JackNetTool.cpp

+ 5
- 10
common/JackNetDriver.cpp View File

@@ -653,7 +653,7 @@ Deactivated for now..
SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
{
char multicast_ip[32];
char net_name[JACK_CLIENT_NAME_SIZE + 1];
char net_name[JACK_CLIENT_NAME_SIZE + 1] = {0};
int udp_port;
int mtu = DEFAULT_MTU;
// Desactivated for now...
@@ -671,19 +671,14 @@ Deactivated for now..
const JSList* node;
const jack_driver_param_t* param;

net_name[0] = 0;

// Possibly use env variable
// Possibly use env variable for UDP port
const char* default_udp_port = getenv("JACK_NETJACK_PORT");
udp_port = (default_udp_port) ? atoi(default_udp_port) : DEFAULT_PORT;

// Possibly use env variable for multicast IP
const char* default_multicast_ip = getenv("JACK_NETJACK_MULTICAST");
if (default_multicast_ip) {
strcpy(multicast_ip, default_multicast_ip);
} else {
strcpy(multicast_ip, DEFAULT_MULTICAST_IP);
}

strcpy(multicast_ip, (default_multicast_ip) ? default_multicast_ip : DEFAULT_MULTICAST_IP);
for (node = params; node; node = jack_slist_next(node)) {
param = (const jack_driver_param_t*) node->data;
switch (param->character)


+ 33
- 15
common/JackNetInterface.cpp View File

@@ -426,7 +426,7 @@ namespace Jack
if (((rx_bytes = fSocket.Recv(fRxBuffer, size, flags)) == SOCKET_ERROR) && fRunning) {
FatalRecvError();
}
packet_header_t* header = reinterpret_cast<packet_header_t*>(fRxBuffer);
PacketHeaderNToH(header, header);
return rx_bytes;
@@ -485,8 +485,13 @@ namespace Jack
return SOCKET_ERROR;
}
}
while ((strcmp(rx_head->fPacketType, "header") != 0) && (rx_head->fDataType != 's'));

while (strcmp(rx_head->fPacketType, "header") != 0);
if (rx_head->fDataType != 's') {
jack_error("Wrong packet type : %c\n", rx_head->fDataType);
return -1;
}
fCurrentCycleOffset = fTxHeader.fCycle - rx_head->fCycle;

if (fCurrentCycleOffset < fMaxCycleOffset) {
@@ -541,7 +546,9 @@ namespace Jack
// This method contains every step of sync packet informations coding
// first of all, clear sync packet
memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams));

// Transport not used for now...
/*
// then, first step : transport
if (fParams.fTransportSync) {
EncodeTransportData();
@@ -551,9 +558,8 @@ namespace Jack
}
// then others (freewheel etc.)
// ...

// Transport not used for now...

*/
// Write active ports list
fTxHeader.fActivePorts = (fNetAudioPlaybackBuffer) ? fNetAudioPlaybackBuffer->ActivePortsToNetwork(fTxData) : 0;
}
@@ -561,6 +567,9 @@ namespace Jack
void JackNetMasterInterface::DecodeSyncPacket()
{
// This method contains every step of sync packet informations decoding process
// Transport not used for now...
/*
// first : transport
if (fParams.fTransportSync) {
// copy received transport data to transport data structure
@@ -570,8 +579,8 @@ namespace Jack
}
// then others
// ...
// Transport not used for now...
*/
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);

// Read active ports list
@@ -862,8 +871,13 @@ namespace Jack
return rx_bytes;
}
}
while ((strcmp(rx_head->fPacketType, "header") != 0) && (rx_head->fDataType != 's'));

while (strcmp(rx_head->fPacketType, "header") != 0);
if (rx_head->fDataType != 's') {
jack_error("Wrong packet type : %c\n", rx_head->fDataType);
return -1;
}
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
SetRcvTimeOut();
@@ -942,6 +956,8 @@ namespace Jack
memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams));

// then first step : transport
// Transport is not used for now...
/*
if (fParams.fTransportSync) {
EncodeTransportData();
TransportDataHToN(&fReturnTransportData, &fReturnTransportData);
@@ -950,8 +966,7 @@ namespace Jack
}
// then others
// ...

// Transport is not used for now...
*/

// Write active ports list
fTxHeader.fActivePorts = (fNetAudioCaptureBuffer) ? fNetAudioCaptureBuffer->ActivePortsToNetwork(fTxData) : 0;
@@ -960,6 +975,9 @@ namespace Jack
void JackNetSlaveInterface::DecodeSyncPacket()
{
// This method contains every step of sync packet informations decoding process
// Transport not used for now...
/*
// first : transport
if (fParams.fTransportSync) {
// copy received transport data to transport data structure
@@ -969,8 +987,8 @@ namespace Jack
}
// then others
// ...
// Transport not used for now...
*/
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);

// Read active ports list


+ 14
- 11
common/JackNetTool.cpp View File

@@ -208,14 +208,22 @@ namespace Jack
fNPorts = nports;
fNetBuffer = net_buffer;

fPortBuffer = new sample_t* [fNPorts];
fPortBuffer = new sample_t*[fNPorts];
fConnectedPorts = new bool[fNPorts];
for (int port_index = 0; port_index < fNPorts; port_index++) {
fPortBuffer[port_index] = NULL;
fConnectedPorts[port_index] = true;
}
}

fLastSubCycle = 0;
fPeriodSize = 0;
fSubPeriodSize = 0;
fSubPeriodBytesSize = 0;
fCycleDuration = 0.f;
fCycleBytesSize = 0;
}
NetAudioBuffer::~NetAudioBuffer()
{
delete [] fConnectedPorts;
@@ -285,19 +293,14 @@ namespace Jack
void NetAudioBuffer::ActivePortsFromNetwork(char* net_buffer, uint32_t port_num)
{
int* active_port_address = (int*)net_buffer;
for (int port_index = 0; port_index < fNPorts; port_index++) {
fConnectedPorts[port_index] = false;
}

for (uint port_index = 0; port_index < port_num; port_index++) {
// Use -1 when port is actually connected on other side
int active_port = ntohl(*active_port_address);
if (active_port >= 0 && active_port < fNPorts) {
fConnectedPorts[active_port] = true;
} else {
jack_error("ActivePortsFromNetwork: incorrect port = %d", active_port);
}
fConnectedPorts[active_port] = true;
active_port_address++;
}
}
@@ -371,7 +374,7 @@ namespace Jack
UpdateParams(active_ports);

/*
jack_log("GetNumPackets packet = %d fPeriodSize = %d fSubPeriodSize = %d fSubPeriodBytesSize = %d",
jack_log("GetNumPackets packet = %d fPeriodSize = %d fSubPeriodSize = %d fSubPeriodBytesSize = %d",
fPeriodSize / fSubPeriodSize, fPeriodSize, fSubPeriodSize, fSubPeriodBytesSize);
*/
return fPeriodSize / fSubPeriodSize; // At least one packet


Loading…
Cancel
Save