mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-07 05:11:43 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@17 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
6fe60d0332
commit
19bd1961d4
1 changed files with 16 additions and 2 deletions
18
client.cpp
18
client.cpp
|
@ -16,8 +16,10 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
|
const size_t ms(50);
|
||||||
//44100 / 20 = 2205
|
//44100 / 20 = 2205
|
||||||
const size_t size(4*2205);
|
const size_t size(44100*4*ms/1000);
|
||||||
|
|
||||||
|
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
|
@ -45,6 +47,15 @@ std::string timeToStr(const timeval& timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string chunkTime(const Chunk& chunk)
|
||||||
|
{
|
||||||
|
timeval ts;
|
||||||
|
ts.tv_sec = chunk.tv_sec;
|
||||||
|
ts.tv_usec = chunk.tv_usec;
|
||||||
|
return timeToStr(ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int diff_ms(const timeval& t1, const timeval& t2)
|
int diff_ms(const timeval& t1, const timeval& t2)
|
||||||
{
|
{
|
||||||
return (((t1.tv_sec - t2.tv_sec) * 1000000) +
|
return (((t1.tv_sec - t2.tv_sec) * 1000000) +
|
||||||
|
@ -72,6 +83,7 @@ void player()
|
||||||
if (chunks.empty())
|
if (chunks.empty())
|
||||||
cv.wait(lck);
|
cv.wait(lck);
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
std::cerr << "Chunks: " << chunks.size() << "\n";
|
||||||
Chunk* chunk = chunks.front();
|
Chunk* chunk = chunks.front();
|
||||||
chunks.pop_front();
|
chunks.pop_front();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
@ -109,7 +121,9 @@ int main (int argc, char *argv[])
|
||||||
subscriber.recv(&update);
|
subscriber.recv(&update);
|
||||||
Chunk* chunk = new Chunk();
|
Chunk* chunk = new Chunk();
|
||||||
memcpy(chunk, update.data(), sizeof(Chunk));
|
memcpy(chunk, update.data(), sizeof(Chunk));
|
||||||
std::cerr << "New chunk: " << getAge(*chunk) << "\n";
|
timeval now;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
std::cerr << "New chunk: " << chunkTime(*chunk) << "\t" << timeToStr(now) << "\t" << getAge(*chunk) << "\n";
|
||||||
|
|
||||||
/* timeDiffs.push_back(diff_ms(now, ts));
|
/* timeDiffs.push_back(diff_ms(now, ts));
|
||||||
if (timeDiffs.size() > 100)
|
if (timeDiffs.size() > 100)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue