mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-19 20:16:15 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@13 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
e292a77822
commit
6ff3dc4980
1 changed files with 13 additions and 7 deletions
20
client.cpp
20
client.cpp
|
@ -46,6 +46,17 @@ int diff_ms(const timeval& t1, const timeval& t2)
|
|||
}
|
||||
|
||||
|
||||
int getAge(const Chunk& chunk)
|
||||
{
|
||||
timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
timeval ts;
|
||||
ts.tv_sec = chunks.front()->tv_sec;
|
||||
ts.tv_usec = chunks.front()->tv_usec;
|
||||
return diff_ms(now, ts);
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
zmq::context_t context (1);
|
||||
|
@ -67,8 +78,6 @@ int main (int argc, char *argv[])
|
|||
{
|
||||
zmq::message_t update;
|
||||
subscriber.recv(&update);
|
||||
timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
// std::cerr << "received\n";
|
||||
// std::istringstream iss(static_cast<char*>(update.data()));
|
||||
// iss >> zipcode >> relhumidity;
|
||||
|
@ -92,14 +101,11 @@ int main (int argc, char *argv[])
|
|||
*/
|
||||
// std::cout << "update\n";
|
||||
chunks.push_back(chunk);
|
||||
timeval ts;
|
||||
ts.tv_sec = chunks.front()->tv_sec;
|
||||
ts.tv_usec = chunks.front()->tv_usec;
|
||||
playing = playing || (diff_ms(now, ts) > 200);
|
||||
playing = playing || (getAge(*chunks.front()) > 200);
|
||||
|
||||
if (playing)
|
||||
{
|
||||
// std::cerr << "Chunk: " << diff_ms(now, ts) << "\n";
|
||||
// std::cerr << "Chunk: " << getAge(*chunks.front()) << "\n";
|
||||
for (size_t n=0; n<size; ++n)
|
||||
std::cout << chunks.front()->payload[n] << std::flush;
|
||||
chunks.pop_front();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue