diff --git a/chunk.cpp b/chunk.cpp index dd6f8cba..f3450992 100644 --- a/chunk.cpp +++ b/chunk.cpp @@ -1,9 +1,11 @@ #include "chunk.h" #include +#include -Chunk::Chunk(WireChunk* _wireChunk) : idx(0), wireChunk(_wireChunk) +Chunk::Chunk(WireChunk* _wireChunk) : idx(0) { + wireChunk = new WireChunk(*_wireChunk); } @@ -19,6 +21,15 @@ bool Chunk::isEndOfChunk() } +bool Chunk::getNext(int16_t& _result) +{ + if (isEndOfChunk()) + return false; + _result = wireChunk->payload[idx++]; + result = true; +} + + int Chunk::read(short* _outputBuffer, int _count) { int result = _count; diff --git a/chunk.h b/chunk.h index bd2020d6..68718972 100644 --- a/chunk.h +++ b/chunk.h @@ -39,6 +39,8 @@ public: int read(short* _outputBuffer, int _count); bool isEndOfChunk(); + bool getNext(int16_t& _result); + inline time_point_ms timePoint() { time_point_ms tp; diff --git a/stream.cpp b/stream.cpp index f34af5f9..8860c1a5 100644 --- a/stream.cpp +++ b/stream.cpp @@ -22,9 +22,9 @@ void Stream::setBufferLen(size_t bufferLenMs) void Stream::addChunk(Chunk* chunk) { - Chunk* c = new Chunk(*chunk); +// Chunk* c = new Chunk(*chunk); // mutex.lock(); - chunks.push_back(c); + chunks.push_back(chunk); // mutex.unlock(); cv.notify_all(); } @@ -56,7 +56,7 @@ time_point_ms Stream::getNextPlayerChunk(short* outputBuffer, int correction) { Chunk* chunk = getNextChunk(); time_point_ms tp = chunk->timePoint(); -/* + if (correction != 0) { float idx(chunk->idx);