diff --git a/client.cpp b/client.cpp index 8d18ecff..9b802a37 100644 --- a/client.cpp +++ b/client.cpp @@ -168,6 +168,8 @@ int main (int argc, char *argv[]) std::cerr << "Unsuccessful in setting thread realtime prio" << std::endl; */ stream = new Stream(); + stream->setBufferLen(bufferMs); + initAudio(); Chunk* chunk;// = new Chunk(); while (1) diff --git a/stream.cpp b/stream.cpp index 9987c6dd..eac0c4ca 100644 --- a/stream.cpp +++ b/stream.cpp @@ -15,6 +15,12 @@ Stream::Stream() : sleep(0), lastPlayerChunk(NULL), median(0), shortMedian(0), l } +void Stream::setBufferLen(size_t bufferLenMs) +{ + bufferMs = bufferLenMs; +} + + void Stream::addChunk(Chunk* chunk) { Chunk* c = new Chunk(*chunk); @@ -213,7 +219,7 @@ void Stream::getChunk(short* outputBuffer, double outputBufferDacTime, unsigned lastUpdate = now; median = pBuffer->median(); shortMedian = pShortBuffer->median(); - if (abs(age) > 300) + if (abs(age) > 700) sleep = age; else if (pShortBuffer->full() && (abs(shortMedian) > WIRE_CHUNK_MS)) sleep = shortMedian; diff --git a/stream.h b/stream.h index b3186ff4..8e743bb9 100644 --- a/stream.h +++ b/stream.h @@ -19,6 +19,7 @@ public: timeval getNextPlayerChunk(short* outputBuffer, int correction = 0); void getSilentPlayerChunk(short* outputBuffer); void getChunk(short* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer); + void setBufferLen(size_t bufferLenMs); private: void sleepMs(int ms);