mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-30 10:47:12 +02:00
clean up
This commit is contained in:
parent
a221e431aa
commit
87ce37df8c
5 changed files with 11 additions and 80 deletions
|
@ -22,6 +22,12 @@
|
||||||
#include<deque>
|
#include<deque>
|
||||||
#include<algorithm>
|
#include<algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
/// Size limited queue
|
||||||
|
/**
|
||||||
|
* Size limited queue with basic statistic functions:
|
||||||
|
* median, mean, percentile
|
||||||
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
class DoubleBuffer
|
class DoubleBuffer
|
||||||
{
|
{
|
||||||
|
@ -37,6 +43,7 @@ public:
|
||||||
buffer.pop_front();
|
buffer.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Median as mean over N values around the median
|
||||||
T median(unsigned int mean = 1) const
|
T median(unsigned int mean = 1) const
|
||||||
{
|
{
|
||||||
if (buffer.empty())
|
if (buffer.empty())
|
||||||
|
|
|
@ -120,30 +120,14 @@ void ControlServer::start()
|
||||||
{
|
{
|
||||||
acceptor_ = make_shared<tcp::acceptor>(*io_service_, tcp::endpoint(tcp::v4(), port_));
|
acceptor_ = make_shared<tcp::acceptor>(*io_service_, tcp::endpoint(tcp::v4(), port_));
|
||||||
startAccept();
|
startAccept();
|
||||||
// acceptThread_ = thread(&ControlServer::acceptor, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlServer::stop()
|
void ControlServer::stop()
|
||||||
{
|
{
|
||||||
acceptor_->cancel();
|
acceptor_->cancel();
|
||||||
// io_service_.stop();
|
std::unique_lock<std::mutex> mlock(mutex_);
|
||||||
/* try
|
|
||||||
{
|
|
||||||
acceptThread_.join();
|
|
||||||
}
|
|
||||||
catch(const exception& e)
|
|
||||||
{
|
|
||||||
logO << "ControlServer::stop exception: " << e.what() << "\n";
|
|
||||||
}
|
|
||||||
*/ std::unique_lock<std::mutex> mlock(mutex_);
|
|
||||||
for (auto it = sessions_.begin(); it != sessions_.end(); ++it)
|
for (auto it = sessions_.begin(); it != sessions_.end(); ++it)
|
||||||
(*it)->stop();
|
(*it)->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//void ControlServer::acceptor()
|
|
||||||
//{
|
|
||||||
// io_service_.run();
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Endpoint for a connected client.
|
/// Endpoint for a connected control client.
|
||||||
/**
|
/**
|
||||||
* Endpoint for a connected client.
|
* Endpoint for a connected control client.
|
||||||
* Messages are sent to the client with the "send" method.
|
* Messages are sent to the client with the "send" method.
|
||||||
* Received messages from the client are passed to the MessageReceiver callback
|
* Received messages from the client are passed to the ControlMessageReceiver callback
|
||||||
*/
|
*/
|
||||||
class ControlSession
|
class ControlSession
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
{
|
|
||||||
"Zone":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"uri": "file:///tmp/SnapCast/snapfifo",
|
|
||||||
"name": "zone 1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uri": "file:///tmp/SnapCast/snapfifo2",
|
|
||||||
"name": "zone 2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
"Client":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"MAC": "00:21:6a:7d:74:fc",
|
|
||||||
"IP": "10.1.2.3",
|
|
||||||
"host": "T400",
|
|
||||||
"version": "1.2",
|
|
||||||
"name": "living room",
|
|
||||||
"volume":
|
|
||||||
{
|
|
||||||
"percent": 90,
|
|
||||||
"muted": true
|
|
||||||
},
|
|
||||||
"lastSeen":
|
|
||||||
{
|
|
||||||
"sec": 99,
|
|
||||||
"usec": 1
|
|
||||||
},
|
|
||||||
"conntected": true,
|
|
||||||
"zone": "file:///tmp/SnapCast/snapfifo",
|
|
||||||
"latency": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"MAC": "11:21:6a:7d:74:fc",
|
|
||||||
"IP": "10.1.2.3",
|
|
||||||
"host": "T400",
|
|
||||||
"version": "1.2",
|
|
||||||
"name": "kitchen",
|
|
||||||
"volume": 0.9,
|
|
||||||
"lastSeen":
|
|
||||||
{
|
|
||||||
"sec": 99,
|
|
||||||
"usec": 1
|
|
||||||
},
|
|
||||||
"status": 0,
|
|
||||||
"zone": "file:///tmp/SnapCast/snapfifo",
|
|
||||||
"latency": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -54,7 +54,6 @@ int main(int argc, char* argv[])
|
||||||
po::options_description desc("Allowed options");
|
po::options_description desc("Allowed options");
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help,h", "produce help message")
|
("help,h", "produce help message")
|
||||||
("test", "for testing")
|
|
||||||
("version,v", "show version number")
|
("version,v", "show version number")
|
||||||
("port,p", po::value<size_t>(&settings.port)->default_value(settings.port), "server port")
|
("port,p", po::value<size_t>(&settings.port)->default_value(settings.port), "server port")
|
||||||
("controlPort", po::value<size_t>(&settings.controlPort)->default_value(settings.controlPort), "Remote control port")
|
("controlPort", po::value<size_t>(&settings.controlPort)->default_value(settings.controlPort), "Remote control port")
|
||||||
|
@ -70,12 +69,6 @@ int main(int argc, char* argv[])
|
||||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||||
po::notify(vm);
|
po::notify(vm);
|
||||||
|
|
||||||
if (vm.count("test"))
|
|
||||||
{
|
|
||||||
Config::instance().test();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.count("help"))
|
if (vm.count("help"))
|
||||||
{
|
{
|
||||||
cout << desc << "\n";
|
cout << desc << "\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue