mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-15 18:16:44 +02:00
Small code cleanup
This commit is contained in:
parent
8238f7a147
commit
0af19ca0cb
2 changed files with 102 additions and 101 deletions
|
@ -155,6 +155,7 @@ void ClientConnection::sendNext()
|
|||
}));
|
||||
}
|
||||
|
||||
|
||||
void ClientConnection::send(const msg::message_ptr& message, const ResultHandler& handler)
|
||||
{
|
||||
strand_.post([this, message, handler]() {
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
using namespace std;
|
||||
|
||||
static constexpr auto LOG_TAG = "Controller";
|
||||
static constexpr auto TIME_SYNC_INTERVAL = 1s;
|
||||
|
||||
Controller::Controller(boost::asio::io_context& io_context, const ClientSettings& settings, std::unique_ptr<MetadataAdapter> meta)
|
||||
: io_context_(io_context), timer_(io_context), settings_(settings), stream_(nullptr), decoder_(nullptr), player_(nullptr), meta_(std::move(meta)),
|
||||
|
@ -88,8 +89,12 @@ std::unique_ptr<Player> Controller::createPlayer(ClientSettings::Player& setting
|
|||
void Controller::getNextMessage()
|
||||
{
|
||||
clientConnection_->getNextMessage([this](const boost::system::error_code& ec, std::unique_ptr<msg::BaseMessage> response) {
|
||||
if (!ec)
|
||||
if (ec)
|
||||
{
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (response->type == message_type::kWireChunk)
|
||||
{
|
||||
if (stream_ && decoder_)
|
||||
|
@ -216,11 +221,6 @@ void Controller::getNextMessage()
|
|||
LOG(WARNING, LOG_TAG) << "Unexpected message received, type: " << response->type << "\n";
|
||||
}
|
||||
getNextMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
reconnect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ void Controller::sendTimeSyncMessage(int quick_syncs)
|
|||
TimeProvider::getInstance().setDiff(response->latency, response->received - response->sent);
|
||||
}
|
||||
|
||||
std::chrono::microseconds next = 1s;
|
||||
std::chrono::microseconds next = TIME_SYNC_INTERVAL;
|
||||
if (quick_syncs > 0)
|
||||
{
|
||||
if (--quick_syncs == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue