if fps is adjusted below 30, not set fps to 30 when changing image quality (#8468)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
		
							parent
							
								
									245f08055f
								
							
						
					
					
						commit
						93133b9a6c
					
				@ -1203,6 +1203,7 @@ pub struct LoginConfigHandler {
 | 
				
			|||||||
    pub save_ab_password_to_recent: bool, // true: connected with ab password
 | 
					    pub save_ab_password_to_recent: bool, // true: connected with ab password
 | 
				
			||||||
    pub other_server: Option<(String, String, String)>,
 | 
					    pub other_server: Option<(String, String, String)>,
 | 
				
			||||||
    pub custom_fps: Arc<Mutex<Option<usize>>>,
 | 
					    pub custom_fps: Arc<Mutex<Option<usize>>>,
 | 
				
			||||||
 | 
					    pub last_auto_fps: Option<usize>,
 | 
				
			||||||
    pub adapter_luid: Option<i64>,
 | 
					    pub adapter_luid: Option<i64>,
 | 
				
			||||||
    pub mark_unsupported: Vec<CodecFormat>,
 | 
					    pub mark_unsupported: Vec<CodecFormat>,
 | 
				
			||||||
    pub selected_windows_session_id: Option<u32>,
 | 
					    pub selected_windows_session_id: Option<u32>,
 | 
				
			||||||
 | 
				
			|||||||
@ -1002,8 +1002,9 @@ impl<T: InvokeUiSession> Remote<T> {
 | 
				
			|||||||
        if limited_fps > custom_fps {
 | 
					        if limited_fps > custom_fps {
 | 
				
			||||||
            limited_fps = custom_fps;
 | 
					            limited_fps = custom_fps;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        let last_auto_fps = self.handler.lc.read().unwrap().last_auto_fps.clone();
 | 
				
			||||||
        let should_decrease = (len > 1
 | 
					        let should_decrease = (len > 1
 | 
				
			||||||
            && ctl.last_auto_fps.clone().unwrap_or(custom_fps as _) > limited_fps)
 | 
					            && last_auto_fps.clone().unwrap_or(custom_fps as _) > limited_fps)
 | 
				
			||||||
            || len > std::cmp::max(1, limited_fps / 2);
 | 
					            || len > std::cmp::max(1, limited_fps / 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // increase judgement
 | 
					        // increase judgement
 | 
				
			||||||
@ -1015,14 +1016,14 @@ impl<T: InvokeUiSession> Remote<T> {
 | 
				
			|||||||
            ctl.idle_counter = 0;
 | 
					            ctl.idle_counter = 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let mut should_increase = false;
 | 
					        let mut should_increase = false;
 | 
				
			||||||
        if let Some(last_auto_fps) = ctl.last_auto_fps.clone() {
 | 
					        if let Some(last_auto_fps) = last_auto_fps.clone() {
 | 
				
			||||||
            // ever set
 | 
					            // ever set
 | 
				
			||||||
            if last_auto_fps + 3 <= limited_fps && ctl.idle_counter > 3 {
 | 
					            if last_auto_fps + 3 <= limited_fps && ctl.idle_counter > 3 {
 | 
				
			||||||
                // limited_fps is 3 larger than last set, and idle time is more than 3 seconds
 | 
					                // limited_fps is 3 larger than last set, and idle time is more than 3 seconds
 | 
				
			||||||
                should_increase = true;
 | 
					                should_increase = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ctl.last_auto_fps.is_none() || should_decrease || should_increase {
 | 
					        if last_auto_fps.is_none() || should_decrease || should_increase {
 | 
				
			||||||
            // limited_fps to ensure decoding is faster than encoding
 | 
					            // limited_fps to ensure decoding is faster than encoding
 | 
				
			||||||
            let mut auto_fps = limited_fps;
 | 
					            let mut auto_fps = limited_fps;
 | 
				
			||||||
            if should_decrease && limited_fps < len {
 | 
					            if should_decrease && limited_fps < len {
 | 
				
			||||||
@ -1041,7 +1042,7 @@ impl<T: InvokeUiSession> Remote<T> {
 | 
				
			|||||||
            self.sender.send(Data::Message(msg)).ok();
 | 
					            self.sender.send(Data::Message(msg)).ok();
 | 
				
			||||||
            log::info!("Set fps to {}", auto_fps);
 | 
					            log::info!("Set fps to {}", auto_fps);
 | 
				
			||||||
            ctl.last_queue_size = len;
 | 
					            ctl.last_queue_size = len;
 | 
				
			||||||
            ctl.last_auto_fps = Some(auto_fps);
 | 
					            self.handler.lc.write().unwrap().last_auto_fps = Some(auto_fps);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // send refresh
 | 
					        // send refresh
 | 
				
			||||||
        for (display, video_queue) in self.video_queue_map.read().unwrap().iter() {
 | 
					        for (display, video_queue) in self.video_queue_map.read().unwrap().iter() {
 | 
				
			||||||
@ -1858,7 +1859,6 @@ struct FpsControl {
 | 
				
			|||||||
    last_queue_size: usize,
 | 
					    last_queue_size: usize,
 | 
				
			||||||
    refresh_times: usize,
 | 
					    refresh_times: usize,
 | 
				
			||||||
    last_refresh_instant: Instant,
 | 
					    last_refresh_instant: Instant,
 | 
				
			||||||
    last_auto_fps: Option<usize>,
 | 
					 | 
				
			||||||
    idle_counter: usize,
 | 
					    idle_counter: usize,
 | 
				
			||||||
    last_active_time: HashMap<usize, Instant>,
 | 
					    last_active_time: HashMap<usize, Instant>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1869,7 +1869,6 @@ impl Default for FpsControl {
 | 
				
			|||||||
            last_queue_size: Default::default(),
 | 
					            last_queue_size: Default::default(),
 | 
				
			||||||
            refresh_times: Default::default(),
 | 
					            refresh_times: Default::default(),
 | 
				
			||||||
            last_refresh_instant: Instant::now(),
 | 
					            last_refresh_instant: Instant::now(),
 | 
				
			||||||
            last_auto_fps: Default::default(),
 | 
					 | 
				
			||||||
            idle_counter: 0,
 | 
					            idle_counter: 0,
 | 
				
			||||||
            last_active_time: Default::default(),
 | 
					            last_active_time: Default::default(),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -410,11 +410,14 @@ impl<T: InvokeUiSession> Session<T> {
 | 
				
			|||||||
            self.send(Data::Message(msg));
 | 
					            self.send(Data::Message(msg));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if value != "custom" {
 | 
					        if value != "custom" {
 | 
				
			||||||
 | 
					            let last_auto_fps = self.lc.read().unwrap().last_auto_fps;
 | 
				
			||||||
 | 
					            if last_auto_fps.unwrap_or(usize::MAX) >= 30 {
 | 
				
			||||||
                // non custom quality use 30 fps
 | 
					                // non custom quality use 30 fps
 | 
				
			||||||
                let msg = self.lc.write().unwrap().set_custom_fps(30, false);
 | 
					                let msg = self.lc.write().unwrap().set_custom_fps(30, false);
 | 
				
			||||||
                self.send(Data::Message(msg));
 | 
					                self.send(Data::Message(msg));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn set_custom_fps(&self, custom_fps: i32) {
 | 
					    pub fn set_custom_fps(&self, custom_fps: i32) {
 | 
				
			||||||
        let msg = self.lc.write().unwrap().set_custom_fps(custom_fps, true);
 | 
					        let msg = self.lc.write().unwrap().set_custom_fps(custom_fps, true);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user