diff --git a/src/MaaCore/Config/Miscellaneous/OcrPack.cpp b/src/MaaCore/Config/Miscellaneous/OcrPack.cpp index df9d4638b8..f4f25a0310 100644 --- a/src/MaaCore/Config/Miscellaneous/OcrPack.cpp +++ b/src/MaaCore/Config/Miscellaneous/OcrPack.cpp @@ -204,7 +204,7 @@ bool asst::OcrPack::check_and_load() rec_option.UseCpu(); det_option.SetCpuThreadNum(cpu_threads); rec_option.SetCpuThreadNum(cpu_threads); - Log.info("FastDeploy macOS mode with rec", cpu_threads, "CPU threads"); + Log.info("FastDeploy macOS mode with", cpu_threads, "CPU threads"); #else det_option.UseCpu(); rec_option.UseCpu(); diff --git a/src/MaaCore/Controller/MacSCKHelper.mm b/src/MaaCore/Controller/MacSCKHelper.mm index ebe160ab7a..063923dcb5 100644 --- a/src/MaaCore/Controller/MacSCKHelper.mm +++ b/src/MaaCore/Controller/MacSCKHelper.mm @@ -82,7 +82,18 @@ struct asst::MacSCKHelper::Impl { asst::MacSCKHelper::Impl::~Impl() { if (m_stream) { - [m_stream stopCaptureWithCompletionHandler:nil]; + auto sem = dispatch_semaphore_create(0); + [m_stream stopCaptureWithCompletionHandler:^(NSError* _Nullable error) { + if (error) { + Log.error("Error stopping capture:", error.localizedDescription.UTF8String); + } + dispatch_semaphore_signal(sem); + }]; + + dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC); + dispatch_semaphore_wait(sem, timeout); + dispatch_release(sem); + [m_stream release]; m_stream = nil; } diff --git a/src/MaaCore/Controller/PlayToolsController.cpp b/src/MaaCore/Controller/PlayToolsController.cpp index 1b06725ff3..0c7d91a655 100644 --- a/src/MaaCore/Controller/PlayToolsController.cpp +++ b/src/MaaCore/Controller/PlayToolsController.cpp @@ -96,7 +96,7 @@ bool asst::PlayToolsController::screencap(cv::Mat& image_payload, bool allow_rec bool asst::PlayToolsController::screencap_rgba(cv::Mat& image_payload, bool allow_reconnect [[maybe_unused]]) { - open(); + if (!open()) return false; uint32_t image_size = 0; try { @@ -131,7 +131,7 @@ bool asst::PlayToolsController::screencap_rgba(cv::Mat& image_payload, bool allo bool asst::PlayToolsController::screencap_bgr(cv::Mat& image_payload, bool allow_reconnect [[maybe_unused]]) { - open(); + if (!open()) return false; std::array header; try { @@ -169,7 +169,7 @@ bool asst::PlayToolsController::screencap_bgr(cv::Mat& image_payload, bool allow bool asst::PlayToolsController::start_game(const std::string& client_type [[maybe_unused]]) { - Log.info("InputText is not supported on iOS"); + Log.info("StartGame is not supported on PlayTools"); return true; } @@ -423,7 +423,7 @@ bool asst::PlayToolsController::fetch_screen_res() bool asst::PlayToolsController::toucher_commit(const TouchPhase phase, const Point& p, const int delay) { - open(); + if (!open()) return false; uint16_t x = socket_ops::host_to_network_short(static_cast(p.x)); uint16_t y = socket_ops::host_to_network_short(static_cast(p.y)); uint8_t payload[5] = { static_cast(phase), 0, 0, 0, 0 };