From 6b24ec6a3d98fafbd059cef3f1af61e6d82e9eee Mon Sep 17 00:00:00 2001 From: badaix Date: Thu, 8 Sep 2022 11:39:36 +0200 Subject: [PATCH] Call read from executor --- server/streamreader/alsa_stream.cpp | 9 ++++++--- server/streamreader/posix_stream.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/streamreader/alsa_stream.cpp b/server/streamreader/alsa_stream.cpp index 275c5647..95457e88 100644 --- a/server/streamreader/alsa_stream.cpp +++ b/server/streamreader/alsa_stream.cpp @@ -24,6 +24,9 @@ #include "common/snap_exception.hpp" #include "common/str_compat.hpp" +// 3rd party headers +#include + // standard headers #include #include @@ -104,7 +107,7 @@ void AlsaStream::start() tvEncodedChunk_ = std::chrono::steady_clock::now(); PcmStream::start(); // wait(read_timer_, std::chrono::milliseconds(chunk_ms_), [this] { do_read(); }); - do_read(); + boost::asio::post(strand_, [this] { do_read(); }); } @@ -377,14 +380,14 @@ void AlsaStream::do_read() { LOG(INFO, LOG_TAG) << "next read < 0 (" << getName() << "): " << std::chrono::duration_cast(next_read).count() / 1000. << " ms\n "; - do_read(); + boost::asio::post(strand_, [this] { do_read(); }); } else { // reading chunk_ms_ took longer than chunk_ms_ resync(-next_read); first_ = true; - do_read(); + boost::asio::post(strand_, [this] { do_read(); }); } lastException_ = ""; diff --git a/server/streamreader/posix_stream.cpp b/server/streamreader/posix_stream.cpp index fad0a8bf..c0bea2a5 100644 --- a/server/streamreader/posix_stream.cpp +++ b/server/streamreader/posix_stream.cpp @@ -150,7 +150,7 @@ void PosixStream::do_read() { LOG(INFO, LOG_TAG) << "next read < 0 (" << getName() << "): " << std::chrono::duration_cast(next_read).count() / 1000. << " ms\n"; - do_read(); + boost::asio::post(strand_, [this] { do_read(); }); } else {