From 72f2afcf24911d90e109047d56d62793a168d295 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@d8a302eb-03bc-478d-80e4-98257eca68ef> Date: Wed, 6 Aug 2014 21:00:51 +0000 Subject: [PATCH] cleanup git-svn-id: svn://elaine/murooma/trunk@147 d8a302eb-03bc-478d-80e4-98257eca68ef --- stream.cpp | 21 ++++----------------- stream.h | 5 ++--- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/stream.cpp b/stream.cpp index 66f0ba35..3e597b93 100644 --- a/stream.cpp +++ b/stream.cpp @@ -24,19 +24,7 @@ void Stream::setBufferLen(size_t bufferLenMs) void Stream::addChunk(Chunk* chunk) { -// Chunk* c = new Chunk(*chunk); -// mutex.lock(); chunks.push(shared_ptr(chunk)); -// mutex.unlock(); -} - - - -shared_ptr Stream::getNextChunk() -{ - if (!chunk) - chunk = chunks.pop(); - return chunk; } @@ -50,7 +38,9 @@ void Stream::getSilentPlayerChunk(short* outputBuffer) time_point_ms Stream::getNextPlayerChunk(short* outputBuffer, int correction) { - chunk = getNextChunk(); + if (!chunk) + chunk = chunks.pop(); + time_point_ms tp = chunk->timePoint(); int read = 0; int toRead = PLAYER_CHUNK_SIZE + correction*PLAYER_CHUNK_MS_SIZE; @@ -65,10 +55,7 @@ time_point_ms Stream::getNextPlayerChunk(short* outputBuffer, int correction) { read += chunk->read(buffer + read, toRead - read); if (chunk->isEndOfChunk()) - { - chunk = NULL; - chunk = getNextChunk(); - } + chunk = chunks.pop(); } if (correction != 0) diff --git a/stream.h b/stream.h index 25df9364..04e263cb 100644 --- a/stream.h +++ b/stream.h @@ -18,13 +18,12 @@ class Stream public: Stream(); void addChunk(Chunk* chunk); - std::shared_ptr getNextChunk(); - time_point_ms 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: + time_point_ms getNextPlayerChunk(short* outputBuffer, int correction = 0); + void getSilentPlayerChunk(short* outputBuffer); void sleepMs(int ms); int sleep;