From d73e0e1e5a2d1b785a51c479f6c7dcd0e49937f5 Mon Sep 17 00:00:00 2001 From: dignow <136106582+dignow@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:41:52 +0800 Subject: [PATCH] fix: video service (#8812) 1. Unset refresh flag if just refreshed. 2. Reduce the scope of the lock. Signed-off-by: dignow --- src/flutter.rs | 2 +- src/server/video_service.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/flutter.rs b/src/flutter.rs index 1e7f1f283..e9065636a 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -1063,7 +1063,7 @@ impl FlutterHandler { } // We need `is_sent` here. Because we use texture render for multi-displays session. // - // Eg. We have to windows, one is display 1, the other is displays 0&1. + // Eg. We have two windows, one is display 1, the other is displays 0&1. // When image of display 0 is received, we will not send the event. // // 1. "display 1" will not send the event. diff --git a/src/server/video_service.rs b/src/server/video_service.rs index 54108515d..e4c16fd82 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -517,16 +517,22 @@ fn run(vs: VideoService) -> ResultType<()> { drop(video_qos); if sp.is_option_true(OPTION_REFRESH) { - let mut last_refresh_lock = LAST_REFRESH_TIME.lock().unwrap(); - if last_refresh_lock + if LAST_REFRESH_TIME + .lock() + .unwrap() .get(&vs.idx) .map(|x| x.elapsed().as_millis() > REFRESH_MIN_INTERVAL_MILLIS) .unwrap_or(true) { let _ = try_broadcast_display_changed(&sp, display_idx, &c, true); - last_refresh_lock.insert(vs.idx, Instant::now()); + LAST_REFRESH_TIME + .lock() + .unwrap() + .insert(vs.idx, Instant::now()); log::info!("switch to refresh"); bail!("SWITCH"); + } else { + sp.set_option_bool(OPTION_REFRESH, false); } } if codec_format != Encoder::negotiated_codec() {