mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: libcamera: use lock when acquiring CameraManager
				
					
				
			Make `libcamera_manager_acquire()` thread safe by locking a mutex when the `CameraManager` instance is created and started.
This commit is contained in:
		
							parent
							
								
									f073a1a59b
								
							
						
					
					
						commit
						5f4f4b5dd3
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -82,10 +82,13 @@ struct impl {
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static std::weak_ptr<CameraManager> global_manager;
 | 
			
		||||
 | 
			
		||||
std::shared_ptr<CameraManager> libcamera_manager_acquire(int& res)
 | 
			
		||||
{
 | 
			
		||||
	static std::weak_ptr<CameraManager> global_manager;
 | 
			
		||||
	static std::mutex lock;
 | 
			
		||||
 | 
			
		||||
	std::lock_guard guard(lock);
 | 
			
		||||
 | 
			
		||||
	if (auto manager = global_manager.lock())
 | 
			
		||||
		return manager;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue