mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-20 04:26:16 +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[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
zmq::context_t context (1);
|
zmq::context_t context (1);
|
||||||
|
@ -67,8 +78,6 @@ int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
zmq::message_t update;
|
zmq::message_t update;
|
||||||
subscriber.recv(&update);
|
subscriber.recv(&update);
|
||||||
timeval now;
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
// std::cerr << "received\n";
|
// std::cerr << "received\n";
|
||||||
// std::istringstream iss(static_cast<char*>(update.data()));
|
// std::istringstream iss(static_cast<char*>(update.data()));
|
||||||
// iss >> zipcode >> relhumidity;
|
// iss >> zipcode >> relhumidity;
|
||||||
|
@ -92,14 +101,11 @@ int main (int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
// std::cout << "update\n";
|
// std::cout << "update\n";
|
||||||
chunks.push_back(chunk);
|
chunks.push_back(chunk);
|
||||||
timeval ts;
|
playing = playing || (getAge(*chunks.front()) > 200);
|
||||||
ts.tv_sec = chunks.front()->tv_sec;
|
|
||||||
ts.tv_usec = chunks.front()->tv_usec;
|
|
||||||
playing = playing || (diff_ms(now, ts) > 200);
|
|
||||||
|
|
||||||
if (playing)
|
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)
|
for (size_t n=0; n<size; ++n)
|
||||||
std::cout << chunks.front()->payload[n] << std::flush;
|
std::cout << chunks.front()->payload[n] << std::flush;
|
||||||
chunks.pop_front();
|
chunks.pop_front();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue