From 30a11bfe0a4166d48e8d39a25311641c8cc166d9 Mon Sep 17 00:00:00 2001 From: 21pages Date: Mon, 25 Nov 2024 21:45:58 +0800 Subject: [PATCH] android wait 3s for isStart flag (#10053) The normal process is that `startCapture` and `VideoService::run` run in parallel, the `run` function waits for startCapture to complete, then sets the scale, and subsequently calls `stopCapture` and `startCapture`. If the `run` function does not wait long enough, `startCapture` initializes the surface with the original width and height, but the `start` flag is still false, meaning it can't call `stopCapture` and `startCapture`. This results in only capturing the upper-left portion of the virtual display. Signed-off-by: 21pages --- src/server/video_service.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server/video_service.rs b/src/server/video_service.rs index eceaf69c1..733405a37 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -845,14 +845,15 @@ fn check_change_scale(hardware: bool) -> ResultType<()> { use hbb_common::config::keys::OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE as SCALE_SOFT; // isStart flag is set at the end of startCapture() in Android, wait it to be set. - for i in 0..6 { + let n = 60; // 3s + for i in 0..n { if scrap::is_start() == Some(true) { log::info!("start flag is set"); break; } log::info!("wait for start, {i}"); std::thread::sleep(Duration::from_millis(50)); - if i == 5 { + if i == n - 1 { log::error!("wait for start timeout"); } }