Fix. Do not get displays on server start.
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
		
							parent
							
								
									d3a33d786d
								
							
						
					
					
						commit
						e09a050d41
					
				| @ -77,6 +77,7 @@ lazy_static::lazy_static! { | |||||||
|     // Now we use this [`CLIENT_SERVER`] to do following operations:
 |     // Now we use this [`CLIENT_SERVER`] to do following operations:
 | ||||||
|     // - record local audio, and send to remote
 |     // - record local audio, and send to remote
 | ||||||
|     pub static ref CLIENT_SERVER: ServerPtr = new(); |     pub static ref CLIENT_SERVER: ServerPtr = new(); | ||||||
|  |     static ref PRIMARY_VIDEO_SERVICE_LOCK: Arc<Mutex<()>> = Default::default(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub struct Server { | pub struct Server { | ||||||
| @ -97,9 +98,6 @@ pub fn new() -> ServerPtr { | |||||||
|     server.add_service(Box::new(audio_service::new())); |     server.add_service(Box::new(audio_service::new())); | ||||||
|     #[cfg(not(target_os = "ios"))] |     #[cfg(not(target_os = "ios"))] | ||||||
|     server.add_service(Box::new(display_service::new())); |     server.add_service(Box::new(display_service::new())); | ||||||
|     server.add_service(Box::new(video_service::new( |  | ||||||
|         *display_service::PRIMARY_DISPLAY_IDX, |  | ||||||
|     ))); |  | ||||||
|     #[cfg(not(any(target_os = "android", target_os = "ios")))] |     #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||||
|     { |     { | ||||||
|         server.add_service(Box::new(clipboard_service::new())); |         server.add_service(Box::new(clipboard_service::new())); | ||||||
| @ -262,6 +260,17 @@ impl Server { | |||||||
|         name.starts_with(video_service::NAME) |         name.starts_with(video_service::NAME) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     pub fn try_add_privay_video_service(&mut self) { | ||||||
|  |         let _lock = PRIMARY_VIDEO_SERVICE_LOCK.lock().unwrap(); | ||||||
|  |         let primary_video_service_name = | ||||||
|  |             video_service::get_service_name(*display_service::PRIMARY_DISPLAY_IDX); | ||||||
|  |         if !self.contains(&primary_video_service_name) { | ||||||
|  |             self.add_service(Box::new(video_service::new( | ||||||
|  |                 *display_service::PRIMARY_DISPLAY_IDX, | ||||||
|  |             ))); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     pub fn add_connection(&mut self, conn: ConnInner, noperms: &Vec<&'static str>) { |     pub fn add_connection(&mut self, conn: ConnInner, noperms: &Vec<&'static str>) { | ||||||
|         let primary_video_service_name = |         let primary_video_service_name = | ||||||
|             video_service::get_service_name(*display_service::PRIMARY_DISPLAY_IDX); |             video_service::get_service_name(*display_service::PRIMARY_DISPLAY_IDX); | ||||||
|  | |||||||
| @ -1244,6 +1244,7 @@ impl Connection { | |||||||
|                 #[cfg(not(any(target_os = "android", target_os = "ios")))] |                 #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||||
|                 let _h = try_start_record_cursor_pos(); |                 let _h = try_start_record_cursor_pos(); | ||||||
|                 self.auto_disconnect_timer = Self::get_auto_disconenct_timer(); |                 self.auto_disconnect_timer = Self::get_auto_disconenct_timer(); | ||||||
|  |                 s.try_add_privay_video_service(); | ||||||
|                 s.add_connection(self.inner.clone(), &noperms); |                 s.add_connection(self.inner.clone(), &noperms); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ lazy_static::lazy_static! { | |||||||
|     static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported(); |     static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported(); | ||||||
|     static ref CHANGED_RESOLUTIONS: Arc<RwLock<HashMap<String, ChangedResolution>>> = Default::default(); |     static ref CHANGED_RESOLUTIONS: Arc<RwLock<HashMap<String, ChangedResolution>>> = Default::default(); | ||||||
|     // Initial primary display index.
 |     // Initial primary display index.
 | ||||||
|     // It should only be updated when the rustdesk server is started, and should not be updated when displays changed.
 |     // It should should not be updated when displays changed.
 | ||||||
|     pub static ref PRIMARY_DISPLAY_IDX: usize = get_primary(); |     pub static ref PRIMARY_DISPLAY_IDX: usize = get_primary(); | ||||||
|     static ref SYNC_DISPLAYS: Arc<Mutex<SyncDisplaysInfo>> = Default::default(); |     static ref SYNC_DISPLAYS: Arc<Mutex<SyncDisplaysInfo>> = Default::default(); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user