Commit 2731c1e8 authored by Stephane Letz's avatar Stephane Letz
Browse files

Correct long standing bug in SyncRecv.

parent af2d6396
...@@ -653,7 +653,7 @@ Deactivated for now.. ...@@ -653,7 +653,7 @@ Deactivated for now..
SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params) SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
{ {
char multicast_ip[32]; 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 udp_port;
int mtu = DEFAULT_MTU; int mtu = DEFAULT_MTU;
// Desactivated for now... // Desactivated for now...
...@@ -671,19 +671,14 @@ Deactivated for now.. ...@@ -671,19 +671,14 @@ Deactivated for now..
const JSList* node; const JSList* node;
const jack_driver_param_t* param; const jack_driver_param_t* param;
net_name[0] = 0; // Possibly use env variable for UDP port
// Possibly use env variable
const char* default_udp_port = getenv("JACK_NETJACK_PORT"); const char* default_udp_port = getenv("JACK_NETJACK_PORT");
udp_port = (default_udp_port) ? atoi(default_udp_port) : DEFAULT_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"); const char* default_multicast_ip = getenv("JACK_NETJACK_MULTICAST");
if (default_multicast_ip) { strcpy(multicast_ip, (default_multicast_ip) ? default_multicast_ip : DEFAULT_MULTICAST_IP);
strcpy(multicast_ip, default_multicast_ip);
} else {
strcpy(multicast_ip, DEFAULT_MULTICAST_IP);
}
for (node = params; node; node = jack_slist_next(node)) { for (node = params; node; node = jack_slist_next(node)) {
param = (const jack_driver_param_t*) node->data; param = (const jack_driver_param_t*) node->data;
switch (param->character) switch (param->character)
......
...@@ -426,7 +426,7 @@ namespace Jack ...@@ -426,7 +426,7 @@ namespace Jack
if (((rx_bytes = fSocket.Recv(fRxBuffer, size, flags)) == SOCKET_ERROR) && fRunning) { if (((rx_bytes = fSocket.Recv(fRxBuffer, size, flags)) == SOCKET_ERROR) && fRunning) {
FatalRecvError(); FatalRecvError();
} }
packet_header_t* header = reinterpret_cast<packet_header_t*>(fRxBuffer); packet_header_t* header = reinterpret_cast<packet_header_t*>(fRxBuffer);
PacketHeaderNToH(header, header); PacketHeaderNToH(header, header);
return rx_bytes; return rx_bytes;
...@@ -485,8 +485,13 @@ namespace Jack ...@@ -485,8 +485,13 @@ namespace Jack
return SOCKET_ERROR; 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; fCurrentCycleOffset = fTxHeader.fCycle - rx_head->fCycle;
if (fCurrentCycleOffset < fMaxCycleOffset) { if (fCurrentCycleOffset < fMaxCycleOffset) {
...@@ -541,7 +546,9 @@ namespace Jack ...@@ -541,7 +546,9 @@ namespace Jack
// This method contains every step of sync packet informations coding // This method contains every step of sync packet informations coding
// first of all, clear sync packet // first of all, clear sync packet
memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams)); memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams));
// Transport not used for now...
/*
// then, first step : transport // then, first step : transport
if (fParams.fTransportSync) { if (fParams.fTransportSync) {
EncodeTransportData(); EncodeTransportData();
...@@ -551,9 +558,8 @@ namespace Jack ...@@ -551,9 +558,8 @@ namespace Jack
} }
// then others (freewheel etc.) // then others (freewheel etc.)
// ... // ...
*/
// Transport not used for now...
// Write active ports list // Write active ports list
fTxHeader.fActivePorts = (fNetAudioPlaybackBuffer) ? fNetAudioPlaybackBuffer->ActivePortsToNetwork(fTxData) : 0; fTxHeader.fActivePorts = (fNetAudioPlaybackBuffer) ? fNetAudioPlaybackBuffer->ActivePortsToNetwork(fTxData) : 0;
} }
...@@ -561,6 +567,9 @@ namespace Jack ...@@ -561,6 +567,9 @@ namespace Jack
void JackNetMasterInterface::DecodeSyncPacket() void JackNetMasterInterface::DecodeSyncPacket()
{ {
// This method contains every step of sync packet informations decoding process // This method contains every step of sync packet informations decoding process
// Transport not used for now...
/*
// first : transport // first : transport
if (fParams.fTransportSync) { if (fParams.fTransportSync) {
// copy received transport data to transport data structure // copy received transport data to transport data structure
...@@ -570,8 +579,8 @@ namespace Jack ...@@ -570,8 +579,8 @@ namespace Jack
} }
// then others // then others
// ... // ...
*/
// Transport not used for now...
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer); packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
// Read active ports list // Read active ports list
...@@ -862,8 +871,13 @@ namespace Jack ...@@ -862,8 +871,13 @@ namespace Jack
return rx_bytes; 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; fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
SetRcvTimeOut(); SetRcvTimeOut();
...@@ -942,6 +956,8 @@ namespace Jack ...@@ -942,6 +956,8 @@ namespace Jack
memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams)); memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams));
// then first step : transport // then first step : transport
// Transport is not used for now...
/*
if (fParams.fTransportSync) { if (fParams.fTransportSync) {
EncodeTransportData(); EncodeTransportData();
TransportDataHToN(&fReturnTransportData, &fReturnTransportData); TransportDataHToN(&fReturnTransportData, &fReturnTransportData);
...@@ -950,8 +966,7 @@ namespace Jack ...@@ -950,8 +966,7 @@ namespace Jack
} }
// then others // then others
// ... // ...
*/
// Transport is not used for now...
// Write active ports list // Write active ports list
fTxHeader.fActivePorts = (fNetAudioCaptureBuffer) ? fNetAudioCaptureBuffer->ActivePortsToNetwork(fTxData) : 0; fTxHeader.fActivePorts = (fNetAudioCaptureBuffer) ? fNetAudioCaptureBuffer->ActivePortsToNetwork(fTxData) : 0;
...@@ -960,6 +975,9 @@ namespace Jack ...@@ -960,6 +975,9 @@ namespace Jack
void JackNetSlaveInterface::DecodeSyncPacket() void JackNetSlaveInterface::DecodeSyncPacket()
{ {
// This method contains every step of sync packet informations decoding process // This method contains every step of sync packet informations decoding process
// Transport not used for now...
/*
// first : transport // first : transport
if (fParams.fTransportSync) { if (fParams.fTransportSync) {
// copy received transport data to transport data structure // copy received transport data to transport data structure
...@@ -969,8 +987,8 @@ namespace Jack ...@@ -969,8 +987,8 @@ namespace Jack
} }
// then others // then others
// ... // ...
*/
// Transport not used for now...
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer); packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
// Read active ports list // Read active ports list
......
...@@ -208,14 +208,22 @@ namespace Jack ...@@ -208,14 +208,22 @@ namespace Jack
fNPorts = nports; fNPorts = nports;
fNetBuffer = net_buffer; fNetBuffer = net_buffer;
fPortBuffer = new sample_t* [fNPorts]; fPortBuffer = new sample_t*[fNPorts];
fConnectedPorts = new bool[fNPorts]; fConnectedPorts = new bool[fNPorts];
for (int port_index = 0; port_index < fNPorts; port_index++) { for (int port_index = 0; port_index < fNPorts; port_index++) {
fPortBuffer[port_index] = NULL; fPortBuffer[port_index] = NULL;
fConnectedPorts[port_index] = true; fConnectedPorts[port_index] = true;
} }
}
fLastSubCycle = 0;
fPeriodSize = 0;
fSubPeriodSize = 0;
fSubPeriodBytesSize = 0;
fCycleDuration = 0.f;
fCycleBytesSize = 0;
}
NetAudioBuffer::~NetAudioBuffer() NetAudioBuffer::~NetAudioBuffer()
{ {
delete [] fConnectedPorts; delete [] fConnectedPorts;
...@@ -285,19 +293,14 @@ namespace Jack ...@@ -285,19 +293,14 @@ namespace Jack
void NetAudioBuffer::ActivePortsFromNetwork(char* net_buffer, uint32_t port_num) void NetAudioBuffer::ActivePortsFromNetwork(char* net_buffer, uint32_t port_num)
{ {
int* active_port_address = (int*)net_buffer; int* active_port_address = (int*)net_buffer;
for (int port_index = 0; port_index < fNPorts; port_index++) { for (int port_index = 0; port_index < fNPorts; port_index++) {
fConnectedPorts[port_index] = false; fConnectedPorts[port_index] = false;
} }
for (uint port_index = 0; port_index < port_num; port_index++) { 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); int active_port = ntohl(*active_port_address);
if (active_port >= 0 && active_port < fNPorts) { fConnectedPorts[active_port] = true;
fConnectedPorts[active_port] = true;
} else {
jack_error("ActivePortsFromNetwork: incorrect port = %d", active_port);
}
active_port_address++; active_port_address++;
} }
} }
...@@ -371,7 +374,7 @@ namespace Jack ...@@ -371,7 +374,7 @@ namespace Jack
UpdateParams(active_ports); 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); fPeriodSize / fSubPeriodSize, fPeriodSize, fSubPeriodSize, fSubPeriodBytesSize);
*/ */
return fPeriodSize / fSubPeriodSize; // At least one packet return fPeriodSize / fSubPeriodSize; // At least one packet
......
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