Commit 8c369f2b authored by Stephane Letz's avatar Stephane Letz
Browse files

Cleanup netjack2 code.

parent e7239f09
...@@ -415,17 +415,6 @@ struct JackNetExtMaster : public JackNetMasterInterface { ...@@ -415,17 +415,6 @@ struct JackNetExtMaster : public JackNetMasterInterface {
fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_input_buffer)[midi_port_index]); fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_input_buffer)[midi_port_index]);
} }
/*
// TODO : use with netmaster/netdriver code
//receive sync
int res = SyncRecv();
if ((res == 0) || (res == SOCKET_ERROR)) {
return res;
}
DecodeSyncPacket();
*/
int res = SyncRecv(); int res = SyncRecv();
switch (res) { switch (res) {
...@@ -773,18 +762,8 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf ...@@ -773,18 +762,8 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf
int Read() int Read()
{ {
// TODO : use with netmaster/netdriver code
//receive sync (launch the cycle) //receive sync (launch the cycle)
/* switch (SyncRecv()) {
if (SyncRecv() == SOCKET_ERROR) {
return SOCKET_ERROR;
}
DecodeSyncPacket();
return DataRecv();
*/
switch (SyncRecv()) {
case SOCKET_ERROR: case SOCKET_ERROR:
return SOCKET_ERROR; return SOCKET_ERROR;
...@@ -795,7 +774,6 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf ...@@ -795,7 +774,6 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf
default: default:
//decode sync //decode sync
//if there is an error, don't return -1, it will skip Write() and the network error probably won't be identified
DecodeSyncPacket(); DecodeSyncPacket();
break; break;
} }
......
...@@ -349,18 +349,6 @@ namespace Jack ...@@ -349,18 +349,6 @@ namespace Jack
//read/write operations--------------------------------------------------------------- //read/write operations---------------------------------------------------------------
int JackNetAdapter::Read() int JackNetAdapter::Read()
{ {
//don't return -1 in case of sync recv failure
//we need the process to continue for network error detection
/*
if (SyncRecv() == SOCKET_ERROR) {
return 0;
}
DecodeSyncPacket();
*/
//don't return -1 in case of sync recv failure
//we need the process to continue for network error detection
switch (SyncRecv()) { switch (SyncRecv()) {
case SOCKET_ERROR: case SOCKET_ERROR:
......
...@@ -521,21 +521,12 @@ namespace Jack ...@@ -521,21 +521,12 @@ namespace Jack
DecodeSyncPacket(); DecodeSyncPacket();
break; break;
} }
/*
if (SyncRecv() == SOCKET_ERROR) {
return SOCKET_ERROR;
}
*/
#ifdef JACK_MONITOR #ifdef JACK_MONITOR
// For timing // For timing
fRcvSyncUst = GetMicroSeconds(); fRcvSyncUst = GetMicroSeconds();
#endif #endif
//decode sync
//if there is an error, don't return -1, it will skip Write() and the network error probably won't be identified
//DecodeSyncPacket();
#ifdef JACK_MONITOR #ifdef JACK_MONITOR
fNetTimeMon->Add(float(GetMicroSeconds() - fRcvSyncUst) / float(fEngineControl->fPeriodUsecs) * 100.f); fNetTimeMon->Add(float(GetMicroSeconds() - fRcvSyncUst) / float(fEngineControl->fPeriodUsecs) * 100.f);
#endif #endif
...@@ -550,15 +541,7 @@ namespace Jack ...@@ -550,15 +541,7 @@ namespace Jack
NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing... NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing...
break; break;
} }
/*
if (res == SOCKET_ERROR) {
return SOCKET_ERROR;
} else if (res == NET_PACKET_ERROR) {
jack_time_t cur_time = GetMicroSeconds();
NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing...
}
*/
//take the time at the beginning of the cycle //take the time at the beginning of the cycle
JackDriver::CycleTakeBeginTime(); JackDriver::CycleTakeBeginTime();
......
...@@ -489,6 +489,8 @@ namespace Jack ...@@ -489,6 +489,8 @@ namespace Jack
if (rx_head->fDataType != 's') { if (rx_head->fDataType != 's') {
jack_error("Wrong packet type : %c", rx_head->fDataType); jack_error("Wrong packet type : %c", rx_head->fDataType);
// Not the last packet..
fRxHeader.fIsLastPckt = 0;
return NET_PACKET_ERROR; return NET_PACKET_ERROR;
} }
...@@ -509,10 +511,12 @@ namespace Jack ...@@ -509,10 +511,12 @@ namespace Jack
int rx_bytes = 0; int rx_bytes = 0;
uint recvd_midi_pckt = 0; uint recvd_midi_pckt = 0;
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer); packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
while (!fRxHeader.fIsLastPckt) { while (!fRxHeader.fIsLastPckt) {
// how much data is queued on the rx buffer ? // how much data is queued on the rx buffer ?
rx_bytes = Recv(fParams.fMtu, MSG_PEEK); rx_bytes = Recv(fParams.fMtu, MSG_PEEK);
//jack_error("DataRecv : rx_bytes %d", rx_bytes);
// error here, problem with recv, just skip the cycle (return -1) // error here, problem with recv, just skip the cycle (return -1)
if (rx_bytes == SOCKET_ERROR) { if (rx_bytes == SOCKET_ERROR) {
...@@ -875,6 +879,8 @@ namespace Jack ...@@ -875,6 +879,8 @@ namespace Jack
if (rx_head->fDataType != 's') { if (rx_head->fDataType != 's') {
jack_error("Wrong packet type : %c", rx_head->fDataType); jack_error("Wrong packet type : %c", rx_head->fDataType);
// Not the last packet...
fRxHeader.fIsLastPckt = 0;
return NET_PACKET_ERROR; return NET_PACKET_ERROR;
} }
......
...@@ -510,13 +510,6 @@ namespace Jack ...@@ -510,13 +510,6 @@ namespace Jack
} }
//receive sync //receive sync
/*
int res = SyncRecv();
if ((res == 0) || (res == SOCKET_ERROR)) {
return res;
}
*/
int res = SyncRecv(); int res = SyncRecv();
switch (res) { switch (res) {
...@@ -526,7 +519,7 @@ namespace Jack ...@@ -526,7 +519,7 @@ namespace Jack
case NET_PACKET_ERROR: case NET_PACKET_ERROR:
// Since sync packet is incorrect, don't decode it and continue with data // Since sync packet is incorrect, don't decode it and continue with data
break; break;
default: default:
//decode sync //decode sync
...@@ -537,21 +530,7 @@ namespace Jack ...@@ -537,21 +530,7 @@ namespace Jack
#ifdef JACK_MONITOR #ifdef JACK_MONITOR
fNetTimeMon->Add((((float)(GetMicroSeconds() - begin_time)) / (float) fPeriodUsecs) * 100.f); fNetTimeMon->Add((((float)(GetMicroSeconds() - begin_time)) / (float) fPeriodUsecs) * 100.f);
#endif #endif
//decode sync
//DecodeSyncPacket();
//receive data
/*
res = DataRecv();
if ((res == 0) || (res == SOCKET_ERROR)) {
return res;
} else if (res == NET_PACKET_ERROR) {
// Well not a real XRun...
JackServerGlobals::fInstance->GetEngine()->NotifyClientXRun(ALL_CLIENTS);
}
*/
//receive data //receive data
res = DataRecv(); res = DataRecv();
switch (res) { switch (res) {
......
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