better server shutdown

This commit is contained in:
badaix 2016-05-01 19:18:18 +02:00
parent 679fbaaca0
commit 2275466d09
2 changed files with 7 additions and 8 deletions

View file

@ -389,6 +389,13 @@ void StreamServer::start()
void StreamServer::stop() void StreamServer::stop()
{ {
// std::lock_guard<std::mutex> mlock(sessionsMutex_);
for (auto session: sessions_)//it = sessions_.begin(); it != sessions_.end(); ++it)
{
if (session)
session->stop();
}
if (controlServer_) if (controlServer_)
{ {
controlServer_->stop(); controlServer_->stop();
@ -406,12 +413,5 @@ void StreamServer::stop()
streamManager_->stop(); streamManager_->stop();
streamManager_ = nullptr; streamManager_ = nullptr;
} }
// std::lock_guard<std::mutex> mlock(sessionsMutex_);
for (auto session: sessions_)//it = sessions_.begin(); it != sessions_.end(); ++it)
{
if (session)
session->stop();
}
} }

View file

@ -87,7 +87,6 @@ const SampleFormat& PcmStream::getSampleFormat() const
void PcmStream::start() void PcmStream::start()
{ {
logD << "PcmStream start: " << sampleFormat_.getFormat() << "\n"; logD << "PcmStream start: " << sampleFormat_.getFormat() << "\n";
//TODO: wrong encoder settings leads to: terminate called after throwing an instance of 'std::system_error' what(): Invalid argument
encoder_->init(this, sampleFormat_); encoder_->init(this, sampleFormat_);
active_ = true; active_ = true;