mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-27 16:06:15 +02:00
sleep
git-svn-id: svn://elaine/murooma/trunk@202 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
7691f6f67a
commit
f521230f41
3 changed files with 41 additions and 28 deletions
|
@ -63,9 +63,14 @@ void player(const std::string& ip, int port)
|
|||
{
|
||||
try
|
||||
{
|
||||
cout << "connect\n";
|
||||
tcp::socket s(io_service);
|
||||
s.connect(*iterator);
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 5;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(s.native(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
|
||||
std::clog << kLogNotice << "connected to " << ip << ":" << port << std::endl;
|
||||
while (true)
|
||||
{
|
||||
WireChunk* wireChunk = new WireChunk();
|
||||
|
@ -89,16 +94,17 @@ cout << "connect\n";
|
|||
stream->addChunk(new Chunk(sampleRate, channels, bps, wireChunk));
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << "\n";
|
||||
std::clog << kLogNotice << "Exception: " << e.what() << ", trying to reconnect" << std::endl;
|
||||
stream->clearChunks();
|
||||
usleep(500*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << "\n";
|
||||
std::clog << kLogNotice << "Exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +263,7 @@ int main (int argc, char *argv[])
|
|||
std::thread playerThread(player, ip, port);
|
||||
|
||||
std::string cmd;
|
||||
/* while (true && (argc > 3))
|
||||
while (true && (argc > 3))
|
||||
{
|
||||
std::cout << "> ";
|
||||
std::getline(std::cin, cmd);
|
||||
|
@ -273,7 +279,7 @@ int main (int argc, char *argv[])
|
|||
stream->setBufferLen(atoi(cmd.c_str()));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
playerThread.join();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue