more cleanup

This commit is contained in:
wangyix 2014-06-04 11:30:35 -07:00
parent b452d08495
commit 25e2f28b02
5 changed files with 23 additions and 18 deletions

View file

@ -35,7 +35,7 @@ void DatagramProcessor::processDatagrams() {
Application* application = Application::getInstance();
NodeList* nodeList = NodeList::getInstance();
while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams()) {
incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(),
@ -45,7 +45,6 @@ void DatagramProcessor::processDatagrams() {
_byteCount += incomingPacket.size();
if (nodeList->packetVersionAndHashMatch(incomingPacket)) {
// only process this packet if we have a match on the packet version
switch (packetTypeForPacket(incomingPacket)) {
case PacketTypeMixedAudio:

View file

@ -15,9 +15,6 @@
#include <QTranslator>
#include <SharedUtil.h>
// DEBUG!!!!!!
#include "DatagramProcessor.h"
int main(int argc, const char * argv[]) {
QElapsedTimer startupTime;
startupTime.start();

View file

@ -151,10 +151,6 @@ void LimitedNodeList::changeSendSocketBufferSize(int numSendBytes) {
}
bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
quint64 start = usecTimestampNow();
quint64 end;
PacketType checkType = packetTypeForPacket(packet);
int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data());
@ -192,14 +188,9 @@ quint64 end;
<< uuidFromPacketHeader(packet);
}
} else {
if ((end = usecTimestampNow()) - start > 100) {
printf("\t\t\t\t version and hash match long diff: %d\n", end - start);
}
return true;
}
return false;
}

View file

@ -1,3 +1,13 @@
//
// MovingPercentile.cpp
// libraries/shared/src
//
// Created by Yixin Wang on 6/4/2014
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "MovingPercentile.h"
MovingPercentile::MovingPercentile(int numSamples, float percentile)
@ -23,7 +33,7 @@ void MovingPercentile::updatePercentile(float sample) {
_sampleAges[i]++;
}
// find index in _samplesSorted to insert new sample.
// find index at which to insert new sample in _samplesSorted
int newSampleIndex;
if (_numExistingSamples < _numSamples) {
// if samples have not been filled yet, this will be the next empty spot
@ -40,7 +50,7 @@ void MovingPercentile::updatePercentile(float sample) {
while (_sampleAges[newSampleIndex] != _numExistingSamples) { newSampleIndex++; }
}
// insert new sample at that index
// insert new sample
_samplesSorted[newSampleIndex] = sample;
_sampleAges[newSampleIndex] = 0;

View file

@ -1,8 +1,16 @@
//
// MovingPercentile.h
// libraries/shared/src
//
// Created by Yixin Wang on 6/4/2014
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_MovingPercentile_h
#define hifi_MovingPercentile_h
class MovingPercentile {
public: