diff --git a/server/publishZeroConf/publish_avahi.cpp b/server/publishZeroConf/publish_avahi.cpp index c46cbc8b..c74e9ba1 100644 --- a/server/publishZeroConf/publish_avahi.cpp +++ b/server/publishZeroConf/publish_avahi.cpp @@ -63,7 +63,7 @@ void PublishAvahi::publish(const std::vector& 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(); diff --git a/server/publishZeroConf/publish_avahi.hpp b/server/publishZeroConf/publish_avahi.hpp index ff29d792..18816f3b 100644 --- a/server/publishZeroConf/publish_avahi.hpp +++ b/server/publishZeroConf/publish_avahi.hpp @@ -51,7 +51,7 @@ private: void poll(); AvahiClient* client_; std::vector services_; - boost::asio::deadline_timer timer_; + boost::asio::steady_timer timer_; }; diff --git a/server/streamreader/asio_stream.hpp b/server/streamreader/asio_stream.hpp index fbfb6fe1..310377af 100644 --- a/server/streamreader/asio_stream.hpp +++ b/server/streamreader/asio_stream.hpp @@ -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 stream_; std::atomic bytes_read_; }; @@ -76,7 +76,7 @@ void AsioStream::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::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(now, tvEncodedChunk_); @@ -161,7 +160,7 @@ void AsioStream::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::do_read() { pcmListener_->onResync(this, currentTick - nextTick_); nextTick_ = currentTick + buffer_ms_; + first_ = true; do_read(); } }); diff --git a/server/streamreader/pipe_stream.cpp b/server/streamreader/pipe_stream.cpp index 1f3dd1ec..05e86707 100644 --- a/server/streamreader/pipe_stream.cpp +++ b/server/streamreader/pipe_stream.cpp @@ -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) { diff --git a/server/streamreader/tcp_stream.cpp b/server/streamreader/tcp_stream.cpp index 72f0dcdc..6409db23 100644 --- a/server/streamreader/tcp_stream.cpp +++ b/server/streamreader/tcp_stream.cpp @@ -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(); diff --git a/server/streamreader/tcp_stream.hpp b/server/streamreader/tcp_stream.hpp index 0bd6cec0..01cc6602 100644 --- a/server/streamreader/tcp_stream.hpp +++ b/server/streamreader/tcp_stream.hpp @@ -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_; };