diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index f5a5afd6bb..8bc45666ce 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -378,7 +378,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect auto start_time = high_resolution_clock::now(); if (m_support_socket && m_server_started && - screencap(m_adb.screencap_raw_by_nc, decode_raw, allow_reconnect, true)) { + screencap(m_adb.screencap_raw_by_nc, decode_raw, allow_reconnect, true, 5000)) { auto duration = duration_cast(high_resolution_clock::now() - start_time); if (duration < min_cost) { m_adb.screencap_method = AdbProperty::ScreencapMethod::RawByNc; @@ -455,13 +455,13 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect } bool asst::AdbController::screencap(const std::string& cmd, const DecodeFunc& decode_func, bool allow_reconnect, - bool by_socket) + bool by_socket, int timeout) { if ((!m_support_socket || !m_server_started) && by_socket) [[unlikely]] { return false; } - auto ret = call_command(cmd, 20000, allow_reconnect, by_socket); + auto ret = call_command(cmd, timeout, allow_reconnect, by_socket); if (!ret || ret.value().empty()) [[unlikely]] { Log.warn("data is empty!"); diff --git a/src/MaaCore/Controller/AdbController.h b/src/MaaCore/Controller/AdbController.h index 617dba468d..a8bc579c50 100644 --- a/src/MaaCore/Controller/AdbController.h +++ b/src/MaaCore/Controller/AdbController.h @@ -63,7 +63,7 @@ namespace asst using DecodeFunc = std::function; bool screencap(const std::string& cmd, const DecodeFunc& decode_func, bool allow_reconnect = false, - bool by_socket = false); + bool by_socket = false, int max_timeout = 20000); void clear_lf_info(); virtual void clear_info() noexcept;