fix: video service (#8812)

1. Unset refresh flag if just refreshed.
2. Reduce the scope of the lock.

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2024-07-24 18:41:52 +08:00 committed by GitHub
parent 39dbd89287
commit d73e0e1e5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -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.

View File

@ -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() {