mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 02:07:55 +02:00
Switch from deadline_timer to steady_timer
This commit is contained in:
parent
6c819b8f0c
commit
210ab80f71
6 changed files with 10 additions and 10 deletions
|
@ -63,7 +63,7 @@ void PublishAvahi::publish(const std::vector<mDNSService>& services)
|
|||
void PublishAvahi::poll()
|
||||
{
|
||||
auto self = shared_from_this();
|
||||
timer_.expires_from_now(boost::posix_time::milliseconds(50));
|
||||
timer_.expires_after(std::chrono::milliseconds(50));
|
||||
timer_.async_wait([self, this](const boost::system::error_code& ec) {
|
||||
if (!ec && (avahi_simple_poll_iterate(simple_poll, 0) == 0))
|
||||
poll();
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
void poll();
|
||||
AvahiClient* client_;
|
||||
std::vector<mDNSService> services_;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::steady_timer timer_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ protected:
|
|||
bool first_;
|
||||
long nextTick_;
|
||||
uint32_t buffer_ms_;
|
||||
boost::asio::deadline_timer read_timer_;
|
||||
boost::asio::deadline_timer state_timer_;
|
||||
boost::asio::steady_timer read_timer_;
|
||||
boost::asio::steady_timer state_timer_;
|
||||
std::unique_ptr<ReadStream> stream_;
|
||||
std::atomic<std::uint64_t> bytes_read_;
|
||||
};
|
||||
|
@ -76,7 +76,7 @@ void AsioStream<ReadStream>::check_state()
|
|||
{
|
||||
uint64_t last_read = bytes_read_;
|
||||
auto self = this->shared_from_this();
|
||||
state_timer_.expires_from_now(boost::posix_time::milliseconds(500 + pcmReadMs_));
|
||||
state_timer_.expires_after(std::chrono::milliseconds(500 + pcmReadMs_));
|
||||
state_timer_.async_wait([self, this, last_read](const boost::system::error_code& ec) {
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -139,7 +139,6 @@ void AsioStream<ReadStream>::do_read()
|
|||
// the timestamp will be incremented after encoding,
|
||||
// since we do not know how much the encoder actually encoded
|
||||
|
||||
|
||||
timeval now;
|
||||
chronos::systemtimeofday(&now);
|
||||
auto stream2systime_diff = chronos::diff<std::chrono::milliseconds>(now, tvEncodedChunk_);
|
||||
|
@ -161,7 +160,7 @@ void AsioStream<ReadStream>::do_read()
|
|||
// Synchronize read to pcmReadMs_
|
||||
if (nextTick_ >= currentTick)
|
||||
{
|
||||
read_timer_.expires_from_now(boost::posix_time::milliseconds(nextTick_ - currentTick));
|
||||
read_timer_.expires_after(std::chrono::milliseconds(nextTick_ - currentTick));
|
||||
read_timer_.async_wait([self, this](const boost::system::error_code& ec) {
|
||||
if (ec)
|
||||
{
|
||||
|
@ -179,6 +178,7 @@ void AsioStream<ReadStream>::do_read()
|
|||
{
|
||||
pcmListener_->onResync(this, currentTick - nextTick_);
|
||||
nextTick_ = currentTick + buffer_ms_;
|
||||
first_ = true;
|
||||
do_read();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ void PipeStream::do_read()
|
|||
|
||||
if (nextTick_ >= currentTick)
|
||||
{
|
||||
read_timer_.expires_from_now(boost::posix_time::milliseconds(nextTick_ - currentTick));
|
||||
read_timer_.expires_after(std::chrono::milliseconds(nextTick_ - currentTick));
|
||||
read_timer_.async_wait([self, this](const boost::system::error_code& ec) {
|
||||
if (ec)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ void TcpStream::connect()
|
|||
else
|
||||
{
|
||||
LOG(DEBUG) << "Connect failed: " << ec.message() << "\n";
|
||||
reconnect_timer_.expires_from_now(boost::posix_time::milliseconds(1000));
|
||||
reconnect_timer_.expires_after(std::chrono::milliseconds(1000));
|
||||
reconnect_timer_.async_wait([self, this](const boost::system::error_code& ec) {
|
||||
if (!ec)
|
||||
connect();
|
||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
|||
std::string host_;
|
||||
size_t port_;
|
||||
bool is_server_;
|
||||
boost::asio::deadline_timer reconnect_timer_;
|
||||
boost::asio::steady_timer reconnect_timer_;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue