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..
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,18 +671,13 @@ 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;
......
......@@ -485,7 +485,12 @@ 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;
......@@ -542,6 +547,8 @@ namespace Jack
// 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,8 +558,7 @@ 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,7 +871,12 @@ 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;
......@@ -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
......
......@@ -208,12 +208,20 @@ 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()
......@@ -291,13 +299,8 @@ namespace Jack
}
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);
}
active_port_address++;
}
}
......
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