extra commit of previous commit?

This commit is contained in:
wangyix 2014-06-03 16:19:12 -07:00
parent c851edd0ef
commit 50746a6540
5 changed files with 162 additions and 5 deletions

View file

@ -149,7 +149,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
int piggyBackSize = nodeData->getPacketLength() + statsMessageLength;
// If the size of the stats message and the voxel message will fit in a packet, then piggyback them
if (piggyBackSize < MAX_PACKET_SIZE) {
if (false && piggyBackSize < MAX_PACKET_SIZE) {
// copy voxel message to back of stats message
memcpy(statsMessage + statsMessageLength, nodeData->getPacket(), nodeData->getPacketLength());

View file

@ -25,7 +25,39 @@ DatagramProcessor::DatagramProcessor(QObject* parent) :
}
// DEBUG
int DatagramProcessor::skewsI[10000];
int DatagramProcessor::S = 0;
unsigned char DatagramProcessor::typesI[10000];
int DatagramProcessor::diffsI[10000];
int DatagramProcessor::I = 0;
quint64 DatagramProcessor::prevTime = 0;
unsigned char DatagramProcessor::typesA[100];
quint64 DatagramProcessor::timesA[100];
int DatagramProcessor::A = 1;
unsigned char DatagramProcessor::typesB[100];
quint64 DatagramProcessor::timesB[100];
int DatagramProcessor::B = 1;
unsigned char* DatagramProcessor::currTypes = typesA;
unsigned char* DatagramProcessor::prevTypes = typesB;
quint64* DatagramProcessor::currTimes = timesA;
quint64* DatagramProcessor::prevTimes = timesB;
int* DatagramProcessor::currN = &A;
int* DatagramProcessor::prevN = &B;
void DatagramProcessor::processDatagrams() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"DatagramProcessor::processDatagrams()");
@ -35,6 +67,30 @@ void DatagramProcessor::processDatagrams() {
Application* application = Application::getInstance();
NodeList* nodeList = NodeList::getInstance();
prevTime = prevTimes[*prevN-1];
// swap
unsigned char* temp = currTypes;
currTypes = prevTypes;
prevTypes = temp;
// swap
quint64* temp2 = currTimes;
currTimes = prevTimes;
prevTimes = temp2;
// swap
int* temp3 = currN;
currN = prevN;
prevN = temp3;
// reset
*currN = 0;
int skew = 0;
while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams()) {
incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
@ -45,8 +101,15 @@ void DatagramProcessor::processDatagrams() {
_byteCount += incomingPacket.size();
if (nodeList->packetVersionAndHashMatch(incomingPacket)) {
PacketType type = packetTypeForPacket(incomingPacket);
currTimes[*currN] = usecTimestampNow();
currTypes[*currN] = (unsigned char)type;
(*currN)++;
// only process this packet if we have a match on the packet version
switch (packetTypeForPacket(incomingPacket)) {
switch (type) { //packetTypeForPacket(incomingPacket)) {
case PacketTypeMixedAudio:
QMetaObject::invokeMethod(&application->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
Q_ARG(QByteArray, incomingPacket));
@ -146,9 +209,54 @@ void DatagramProcessor::processDatagrams() {
break;
}
default:
nodeList->processNodeData(senderSockAddr, incomingPacket);
int s = nodeList->processNodeData(senderSockAddr, incomingPacket);
if (s!=1234567890)
skew = s;
break;
}
}
}
if (abs(skew) > 1000) {
printf("large skew! %d ----------------------------\n", skew);
skewsI[S++] = skew;
/*
printf("prev:::::::::::::::::::::::::::::::::::::\n");
printf("\t type: %d time: %llu diff: %llu\n", prevTypes[0], prevTimes[0] % 100000000, prevTimes[0] - prevTime);
for (int i = 1; i < *prevN; i++) {
printf("\t type: %d time: %llu diff: %llu\n", prevTypes[i], prevTimes[i] % 100000000, prevTimes[i] - prevTimes[i - 1]);
}
printf("curr:::::::::::::::::::::::::::::::::::::\n");
printf("\t type: %d time: %llu diff: %llu\n", currTypes[0], currTimes[0] % 100000000, currTimes[0] - prevTimes[*prevN - 1]);
for (int i = 1; i < *currN; i++) {
printf("\t type: %d time: %llu diff: %llu\n", currTypes[i], currTimes[i] % 100000000, currTimes[i] - currTimes[i - 1]);
}*/
diffsI[I++] = -2; // prev marker
typesI[I] = prevTypes[0];
diffsI[I++] = prevTimes[0] - prevTime;
for (int i = 1; i < *prevN; i++) {
typesI[I] = prevTypes[i];
diffsI[I++] = prevTimes[i] - prevTimes[i - 1];
}
diffsI[I++] = -1; // curr marker
typesI[I] = currTypes[0];
diffsI[I++] = currTimes[0] - prevTimes[*prevN - 1];
for (int i = 1; i < *currN; i++) {
typesI[I] = currTypes[i];
diffsI[I++] = currTimes[i] - currTimes[i - 1];
}
}
skew = 0;
}

View file

@ -29,6 +29,32 @@ public slots:
private:
int _packetCount;
int _byteCount;
public:
// DEBUG
static int skewsI[];
static int S;
static unsigned char typesI[];
static int diffsI[];
static int I;
static quint64 prevTime;
static unsigned char typesA[];
static quint64 timesA[];
static int A;
static unsigned char typesB[];
static quint64 timesB[];
static int B;
static unsigned char* currTypes, *prevTypes;
static quint64* currTimes, *prevTimes;
static int* currN, *prevN;
};
#endif // hifi_DatagramProcessor_h

View file

@ -15,6 +15,9 @@
#include <QTranslator>
#include <SharedUtil.h>
// DEBUG!!!!!!
#include "DatagramProcessor.h"
int main(int argc, const char * argv[]) {
QElapsedTimer startupTime;
startupTime.start();
@ -43,5 +46,25 @@ int main(int argc, const char * argv[]) {
exitCode = app.exec();
}
qDebug("Normal exit.");
int s = 0;
for (int i = 0; i < DatagramProcessor::I; i++) {
switch (DatagramProcessor::diffsI[i]) {
case -2:
printf("\nskew: %d\n", DatagramProcessor::skewsI[s++]);
printf("prev:::::::::::::::::::::::::::::::\n");
break;
case -1:
printf("curr:::::::::::::::::::::::::::::::\n");
break;
default:
printf("\t type: %d diff: %d\n", DatagramProcessor::typesI[i], DatagramProcessor::diffsI[i]);
break;
}
}
return exitCode;
}

View file

@ -63,7 +63,7 @@ public:
void addSetOfNodeTypesToNodeInterestSet(const NodeSet& setOfNodeTypes);
void resetNodeInterestSet() { _nodeTypesOfInterest.clear(); }
void processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
int processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
int processDomainServerList(const QByteArray& packet);
@ -95,7 +95,7 @@ private:
void processDomainServerAuthRequest(const QByteArray& packet);
void requestAuthForDomainServer();
void activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode);
void timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
int timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
NodeType_t _ownerType;
NodeSet _nodeTypesOfInterest;