mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix: macOS PlayTools/SCK 几处小修正 (#16276)
fix: macOS 相关几处小修正 - PlayToolsController: screencap_rgba/screencap_bgr/toucher_commit 调用 open() 时未检查返回值,连接失败时继续操作会写坏的 socket - PlayToolsController: start_game() 日志写成了 InputText,应该是 StartGame - OcrPack: macOS 分支日志里残留了多余的 "rec" 字样 - MacSCKHelper: 析构时 stopCapture 是异步的,没等回调完成就释放了 stream/output/queue,可能踩到野指针;改用信号量等停完再释放
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<uint32_t, 3> 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<uint16_t>(p.x));
|
||||
uint16_t y = socket_ops::host_to_network_short(static_cast<uint16_t>(p.y));
|
||||
uint8_t payload[5] = { static_cast<uint8_t>(phase), 0, 0, 0, 0 };
|
||||
|
||||
Reference in New Issue
Block a user