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 <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-11-25 21:45:58 +08:00 committed by GitHub
parent 9d2bdfefb1
commit 30a11bfe0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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; 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. // 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) { if scrap::is_start() == Some(true) {
log::info!("start flag is set"); log::info!("start flag is set");
break; break;
} }
log::info!("wait for start, {i}"); log::info!("wait for start, {i}");
std::thread::sleep(Duration::from_millis(50)); std::thread::sleep(Duration::from_millis(50));
if i == 5 { if i == n - 1 {
log::error!("wait for start timeout"); log::error!("wait for start timeout");
} }
} }