git-svn-id: svn://elaine/murooma/trunk@182 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-08-11 20:42:35 +00:00
parent d3c79f93f0
commit 3e6a1e5b07
6 changed files with 22 additions and 20 deletions

View file

@ -28,14 +28,14 @@ public:
return tmpBuffer[tmpBuffer.size() / 2];
}
T mean() const
double mean() const
{
if (buffer.empty())
return 0;
double mean = 0.;
for (size_t n=0; n<buffer.size(); ++n)
mean += (float)buffer[n] / (float)buffer.size();
return (T)mean;
return mean;
}
T percentil(unsigned int percentil) const

View file

@ -46,9 +46,9 @@ void player()
cout << "connect\n";
tcp::socket s(io_service);
s.connect(*iterator);
void* wireChunk = (void*)malloc(sizeof(WireChunk));
while (true)
{
void* wireChunk = (void*)malloc(sizeof(WireChunk));
size_t toRead = sizeof(WireChunk);
size_t len = 0;
do

View file

@ -9,7 +9,7 @@ Stream::Stream() : sleep(0), median(0), shortMedian(0), lastUpdate(0), latencyMs
{
pBuffer = new DoubleBuffer<int>(1000);
pShortBuffer = new DoubleBuffer<int>(200);
pMiniBuffer = new DoubleBuffer<int>(10);
pMiniBuffer = new DoubleBuffer<int>(20);
pCardBuffer = new DoubleBuffer<int>(50);
bufferMs = 500;
}
@ -175,24 +175,19 @@ void Stream::getPlayerChunk(short* outputBuffer, double outputBufferDacTime, uns
if (sleep == 0)
{
if (pBuffer->full() && (abs(median) <= 10) && (abs(median) > 1))
if (pBuffer->full() && (abs(median) > 1))
{
cout << "pBuffer->full() && (abs(median) <= 10) && (abs(median) > 1): " << abs(median) << "\n";
cout << "pBuffer->full() && (abs(median) > 1): " << median << "\n";
sleep = median;
}
else if (pShortBuffer->full() && (abs(shortMedian) <= 10) && (abs(shortMedian) > 5))
else if (pShortBuffer->full() && (abs(shortMedian) > 5))
{
cout << "pShortBuffer->full() && (abs(shortMedian) <= 10) && (abs(shortMedian) > 5): " << abs(shortMedian) << "\n";
cout << "pShortBuffer->full() && (abs(shortMedian) > 5): " << shortMedian << "\n";
sleep = shortMedian;
}
if (pShortBuffer->full() && (abs(shortMedian) > 10))
else if (pMiniBuffer->full() && (abs(pMiniBuffer->median()) > 50))
{
cout << "pShortBuffer->full() && (abs(shortMedian) > 10): " << abs(shortMedian) << "\n";
sleep = shortMedian;
}
else if (pMiniBuffer->full() && (abs(age) > 50) && (abs(pMiniBuffer->mean()) > 50))
{
cout << "pMiniBuffer->full() && (abs(age) > 50) && (abs(pMiniBuffer->mean()) > 50): " << abs(age) << "\n";
cout << "pMiniBuffer->full() && (abs(pMiniBuffer->mean()) > 50): " << pMiniBuffer->median() << "\n";
sleep = pMiniBuffer->mean();
}
}
@ -212,8 +207,8 @@ void Stream::getPlayerChunk(short* outputBuffer, double outputBufferDacTime, uns
{
lastUpdate = now;
median = pBuffer->median();
shortMedian = pShortBuffer->mean();
std::cerr << "Chunk: " << age << "\t" << pMiniBuffer->mean() << "\t" << shortMedian << "\t" << median << /*"\tmean: " << pBuffer->mean() <<*/ "\t" << pBuffer->size() << "\t" << cardBuffer << "\t" << outputBufferDacTime*1000 << "\n";
shortMedian = pShortBuffer->median();
std::cerr << "Chunk: " << age << "\t" << pMiniBuffer->median() << "\t" << shortMedian << "\t" << median << "\t" << pBuffer->size() << "\t" << cardBuffer << "\t" << outputBufferDacTime*1000 << "\n";
}
}

View file

@ -29,7 +29,7 @@ private:
void resetBuffers();
long lastTick;
float sleep;
int sleep;
// int correction;
Queue<std::shared_ptr<Chunk>> chunks;

View file

@ -3,9 +3,8 @@
#include <iostream>
Chunk::Chunk(WireChunk* _wireChunk) : idx(0)
Chunk::Chunk(WireChunk* _wireChunk) : idx(0), wireChunk(_wireChunk)
{
wireChunk = new WireChunk(*_wireChunk);
}

View file

@ -72,6 +72,14 @@ static long getTickCount()
}
static long getuTickCount()
{
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec*1000000 + now.tv_nsec / 1000;
}
#endif