mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-24 14:36:15 +02:00
Reformat code
This commit is contained in:
parent
58e82ef9e8
commit
d5677b6f78
31 changed files with 236 additions and 330 deletions
|
@ -122,9 +122,8 @@ std::vector<std::string> Controller::getSupportedPlayerNames()
|
|||
|
||||
void Controller::getNextMessage()
|
||||
{
|
||||
clientConnection_->getNextMessage(
|
||||
[this](const boost::system::error_code& ec, std::unique_ptr<msg::BaseMessage> response)
|
||||
{
|
||||
clientConnection_->getNextMessage([this](const boost::system::error_code& ec, std::unique_ptr<msg::BaseMessage> response)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
reconnect();
|
||||
|
@ -227,9 +226,8 @@ void Controller::getNextMessage()
|
|||
if (!player_)
|
||||
throw SnapException("No audio player support" + (settings_.player.player_name.empty() ? "" : " for: " + settings_.player.player_name));
|
||||
|
||||
player_->setVolumeCallback(
|
||||
[this](const Player::Volume& volume)
|
||||
{
|
||||
player_->setVolumeCallback([this](const Player::Volume& volume)
|
||||
{
|
||||
// Cache the last volume and check if it really changed in the player's volume callback
|
||||
static Player::Volume last_volume{-1, true};
|
||||
if (volume != last_volume)
|
||||
|
@ -238,9 +236,8 @@ void Controller::getNextMessage()
|
|||
auto info = std::make_shared<msg::ClientInfo>();
|
||||
info->setVolume(static_cast<uint16_t>(volume.volume * 100.));
|
||||
info->setMuted(volume.mute);
|
||||
clientConnection_->send(info,
|
||||
[this](const boost::system::error_code& ec)
|
||||
{
|
||||
clientConnection_->send(info, [this](const boost::system::error_code& ec)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Failed to send client info, error: " << ec.message() << "\n";
|
||||
|
@ -272,7 +269,7 @@ void Controller::sendTimeSyncMessage(int quick_syncs)
|
|||
auto timeReq = std::make_shared<msg::Time>();
|
||||
clientConnection_->sendRequest<msg::Time>(timeReq, 2s,
|
||||
[this, quick_syncs](const boost::system::error_code& ec, const std::unique_ptr<msg::Time>& response) mutable
|
||||
{
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Time sync request failed: " << ec.message() << "\n";
|
||||
|
@ -293,9 +290,8 @@ void Controller::sendTimeSyncMessage(int quick_syncs)
|
|||
next = 100us;
|
||||
}
|
||||
timer_.expires_after(next);
|
||||
timer_.async_wait(
|
||||
[this, quick_syncs](const boost::system::error_code& ec)
|
||||
{
|
||||
timer_.async_wait([this, quick_syncs](const boost::system::error_code& ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
sendTimeSyncMessage(quick_syncs);
|
||||
|
@ -327,9 +323,8 @@ void Controller::browseMdns(const MdnsHandler& handler)
|
|||
}
|
||||
|
||||
timer_.expires_after(500ms);
|
||||
timer_.async_wait(
|
||||
[this, handler](const boost::system::error_code& ec)
|
||||
{
|
||||
timer_.async_wait([this, handler](const boost::system::error_code& ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
browseMdns(handler);
|
||||
|
@ -348,9 +343,8 @@ void Controller::start()
|
|||
{
|
||||
if (settings_.server.host.empty())
|
||||
{
|
||||
browseMdns(
|
||||
[this](const boost::system::error_code& ec, const std::string& host, uint16_t port)
|
||||
{
|
||||
browseMdns([this](const boost::system::error_code& ec, const std::string& host, uint16_t port)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Failed to browse MDNS, error: " << ec.message() << "\n";
|
||||
|
@ -387,9 +381,8 @@ void Controller::reconnect()
|
|||
stream_.reset();
|
||||
decoder_.reset();
|
||||
timer_.expires_after(1s);
|
||||
timer_.async_wait(
|
||||
[this](const boost::system::error_code& ec)
|
||||
{
|
||||
timer_.async_wait([this](const boost::system::error_code& ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
worker();
|
||||
|
@ -399,9 +392,8 @@ void Controller::reconnect()
|
|||
|
||||
void Controller::worker()
|
||||
{
|
||||
clientConnection_->connect(
|
||||
[this](const boost::system::error_code& ec)
|
||||
{
|
||||
clientConnection_->connect([this](const boost::system::error_code& ec)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
// LOG(INFO, LOG_TAG) << "Connected!\n";
|
||||
|
@ -412,9 +404,8 @@ void Controller::worker()
|
|||
// Say hello to the server
|
||||
auto hello = std::make_shared<msg::Hello>(macAddress, settings_.host_id, settings_.instance);
|
||||
clientConnection_->sendRequest<msg::ServerSettings>(
|
||||
hello, 2s,
|
||||
[this](const boost::system::error_code& ec, std::unique_ptr<msg::ServerSettings> response) mutable
|
||||
{
|
||||
hello, 2s, [this](const boost::system::error_code& ec, std::unique_ptr<msg::ServerSettings> response) mutable
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Failed to send hello request, error: " << ec.message() << "\n";
|
||||
|
@ -427,7 +418,7 @@ void Controller::worker()
|
|||
LOG(INFO, LOG_TAG) << "ServerSettings - buffer: " << serverSettings_->getBufferMs() << ", latency: " << serverSettings_->getLatency()
|
||||
<< ", volume: " << serverSettings_->getVolume() << ", muted: " << serverSettings_->isMuted() << "\n";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Do initial time sync with the server
|
||||
sendTimeSyncMessage(50);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue