mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-10 07:36:41 +02:00
clean
git-svn-id: svn://elaine/murooma/trunk@318 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
83eed0be78
commit
bccffc7432
4 changed files with 37 additions and 11 deletions
|
@ -60,7 +60,10 @@ void Controller::start(const PcmDevice& pcmDevice, const std::string& _ip, size_
|
|||
|
||||
void Controller::stop()
|
||||
{
|
||||
cout << "Stopping\n";
|
||||
active_ = false;
|
||||
controllerThread->join();
|
||||
clientConnection->stop();
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,16 +80,16 @@ void Controller::worker()
|
|||
clientConnection->start();
|
||||
RequestMsg requestMsg(serversettings);
|
||||
shared_ptr<ServerSettings> serverSettings(NULL);
|
||||
while (!(serverSettings = clientConnection->sendReq<ServerSettings>(&requestMsg)));
|
||||
while (active_ && !(serverSettings = clientConnection->sendReq<ServerSettings>(&requestMsg)));
|
||||
cout << "ServerSettings buffer: " << serverSettings->bufferMs << "\n";
|
||||
|
||||
requestMsg.request = sampleformat;
|
||||
while (!(sampleFormat = clientConnection->sendReq<SampleFormat>(&requestMsg)));
|
||||
while (active_ && !(sampleFormat = clientConnection->sendReq<SampleFormat>(&requestMsg)));
|
||||
cout << "SampleFormat rate: " << sampleFormat->rate << ", bits: " << sampleFormat->bits << ", channels: " << sampleFormat->channels << "\n";
|
||||
|
||||
requestMsg.request = header;
|
||||
shared_ptr<HeaderMessage> headerChunk(NULL);
|
||||
while (!(headerChunk = clientConnection->sendReq<HeaderMessage>(&requestMsg)));
|
||||
while (active_ && !(headerChunk = clientConnection->sendReq<HeaderMessage>(&requestMsg)));
|
||||
cout << "Codec: " << headerChunk->codec << "\n";
|
||||
if (headerChunk->codec == "ogg")
|
||||
decoder = new OggDecoder();
|
||||
|
@ -95,7 +98,7 @@ void Controller::worker()
|
|||
decoder->setHeader(headerChunk.get());
|
||||
|
||||
RequestMsg timeReq(timemsg);
|
||||
for (size_t n=0; n<50; ++n)
|
||||
for (size_t n=0; n<50 && active_; ++n)
|
||||
{
|
||||
shared_ptr<TimeMsg> reply = clientConnection->sendReq<TimeMsg>(&timeReq, chronos::msec(2000));
|
||||
if (reply)
|
||||
|
@ -115,7 +118,7 @@ void Controller::worker()
|
|||
|
||||
CommandMsg startStream("startStream");
|
||||
shared_ptr<AckMsg> ackMsg(NULL);
|
||||
while (!(ackMsg = clientConnection->sendReq<AckMsg>(&startStream)));
|
||||
while (active_ && !(ackMsg = clientConnection->sendReq<AckMsg>(&startStream)));
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -152,9 +155,11 @@ void Controller::worker()
|
|||
cout << "Stopping clientConnection\n";
|
||||
clientConnection->stop();
|
||||
cout << "done\n";
|
||||
usleep(1000000);
|
||||
if (active_)
|
||||
usleep(1000000);
|
||||
}
|
||||
}
|
||||
cout << "Thread stopped\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue