mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-10 23:56:43 +02:00
server tick
git-svn-id: svn://elaine/murooma/trunk@107 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
9c06a55331
commit
29d7fd372f
2 changed files with 15 additions and 9 deletions
19
server.cpp
19
server.cpp
|
@ -30,9 +30,8 @@ int main () {
|
|||
|
||||
char c[2];
|
||||
Chunk* chunk = new Chunk();
|
||||
timeval start;
|
||||
timeval now;
|
||||
gettimeofday(&start, NULL);
|
||||
timeval tvChunk;
|
||||
gettimeofday(&tvChunk, NULL);
|
||||
long nextTick = getTickCount();
|
||||
while (cin.good())
|
||||
{
|
||||
|
@ -43,23 +42,25 @@ int main () {
|
|||
chunk->payload[n] = (int)c[0] + ((int)c[1] * 256);
|
||||
}
|
||||
|
||||
chunk->tv_sec = start.tv_sec;
|
||||
chunk->tv_usec = start.tv_usec;
|
||||
chunk->tv_sec = tvChunk.tv_sec;
|
||||
chunk->tv_usec = tvChunk.tv_usec;
|
||||
chunk->idx = 0;
|
||||
zmq::message_t message(sizeof(Chunk));
|
||||
memcpy(message.data(), chunk, sizeof(Chunk));
|
||||
publisher.send(message);
|
||||
addMs(start, WIRE_CHUNK_MS);
|
||||
addMs(tvChunk, WIRE_CHUNK_MS);
|
||||
|
||||
nextTick += WIRE_CHUNK_MS;
|
||||
long currentTick = getTickCount();
|
||||
if (nextTick - currentTick > 0)
|
||||
{
|
||||
usleep((nextTick - currentTick) * 1000);
|
||||
}
|
||||
else
|
||||
gettimeofday(&start, NULL);
|
||||
|
||||
nextTick += WIRE_CHUNK_MS;
|
||||
{
|
||||
gettimeofday(&tvChunk, NULL);
|
||||
nextTick = getTickCount();
|
||||
}
|
||||
}
|
||||
delete chunk;
|
||||
return 0;
|
||||
|
|
|
@ -153,6 +153,7 @@ void Stream::getChunk(short* outputBuffer, double outputBufferDacTime, unsigned
|
|||
{
|
||||
// std::cerr << "Sleep: " << sleep << "\n";
|
||||
getNextPlayerChunk(outputBuffer);
|
||||
usleep(10);
|
||||
}
|
||||
sleep = 0;
|
||||
}
|
||||
|
@ -203,7 +204,11 @@ void Stream::getChunk(short* outputBuffer, double outputBufferDacTime, unsigned
|
|||
// sleep = median;
|
||||
//sleep = 0;
|
||||
if (sleep != 0)
|
||||
{
|
||||
std::cerr << "Sleep: " << sleep << "\n";
|
||||
for (size_t i=0; i<chunks.size(); ++i)
|
||||
std::cerr << "Chunk " << i << ": " << getAge(chunks[i]) - bufferMs << "\n";
|
||||
}
|
||||
//sleep = 0;
|
||||
std::cerr << "Chunk: " << age << "\t" << shortMedian << "\t" << median << "\t" << pBuffer->size() << "\t" << outputBufferDacTime*1000 << "\n";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue