mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-23 19:38:31 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@126 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
56d028a9f0
commit
32acdc83f2
2 changed files with 26 additions and 2 deletions
26
stream.cpp
26
stream.cpp
|
@ -4,7 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
Stream::Stream() : sleep(0), median(0), shortMedian(0), lastUpdate(0)
|
Stream::Stream() : sleep(0), median(0), shortMedian(0), lastUpdate(0), currentSample(0), everyN(40000)
|
||||||
{
|
{
|
||||||
pBuffer = new DoubleBuffer<int>(15000 / PLAYER_CHUNK_MS);
|
pBuffer = new DoubleBuffer<int>(15000 / PLAYER_CHUNK_MS);
|
||||||
pShortBuffer = new DoubleBuffer<int>(5000 / PLAYER_CHUNK_MS);
|
pShortBuffer = new DoubleBuffer<int>(5000 / PLAYER_CHUNK_MS);
|
||||||
|
@ -77,7 +77,28 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE;
|
int idx(chunk->idx);
|
||||||
|
for (size_t n=0; n<PLAYER_CHUNK_SIZE; n+=2)
|
||||||
|
{
|
||||||
|
*(outputBuffer + n) = chunk->payload[idx];
|
||||||
|
*(outputBuffer + n+1) = chunk->payload[idx + 1];
|
||||||
|
idx += 2;
|
||||||
|
if (++currentSample > everyN)
|
||||||
|
{
|
||||||
|
idx += 2;
|
||||||
|
currentSample = 0;
|
||||||
|
}
|
||||||
|
if (idx >= WIRE_CHUNK_SIZE)
|
||||||
|
{
|
||||||
|
chunks.pop_front();
|
||||||
|
delete chunk;
|
||||||
|
chunk = getNextChunk();
|
||||||
|
idx -= WIRE_CHUNK_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chunk->idx = idx;
|
||||||
|
|
||||||
|
/* size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE;
|
||||||
if (chunk->idx + PLAYER_CHUNK_SIZE > WIRE_CHUNK_SIZE)
|
if (chunk->idx + PLAYER_CHUNK_SIZE > WIRE_CHUNK_SIZE)
|
||||||
{
|
{
|
||||||
if (outputBuffer != NULL)
|
if (outputBuffer != NULL)
|
||||||
|
@ -97,6 +118,7 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction)
|
||||||
chunks.pop_front();
|
chunks.pop_front();
|
||||||
delete chunk;
|
delete chunk;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return tv;
|
return tv;
|
||||||
|
|
2
stream.h
2
stream.h
|
@ -25,6 +25,8 @@ private:
|
||||||
void updateChunkTime(Chunk* chunk);
|
void updateChunkTime(Chunk* chunk);
|
||||||
void sleepMs(int ms);
|
void sleepMs(int ms);
|
||||||
|
|
||||||
|
size_t currentSample;
|
||||||
|
int everyN;
|
||||||
int sleep;
|
int sleep;
|
||||||
std::deque<Chunk*> chunks;
|
std::deque<Chunk*> chunks;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue