| 
					
				 | 
			
			
				@@ -44,6 +44,8 @@ static void *gpu_encode_thread(void *unused) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		os_event_reset(video->gpu_encode_inactive); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		/* -------------- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		pthread_mutex_lock(&video->gpu_encoder_mutex); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -128,6 +130,8 @@ static void *gpu_encode_thread(void *unused) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		pthread_mutex_unlock(&video->gpu_encoder_mutex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		os_event_signal(video->gpu_encode_inactive); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	da_free(encoders); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -168,10 +172,14 @@ bool init_gpu_encoding(struct obs_core_video *video) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if (os_sem_init(&video->gpu_encode_semaphore, 0) != 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if (os_event_init(&video->gpu_encode_inactive, OS_EVENT_TYPE_MANUAL) != 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if (pthread_create(&video->gpu_encode_thread, NULL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				gpu_encode_thread, NULL) != 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	os_event_signal(video->gpu_encode_inactive); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	video->gpu_encode_thread_initialized = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #else 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -196,6 +204,10 @@ void free_gpu_encoding(struct obs_core_video *video) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		os_sem_destroy(video->gpu_encode_semaphore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		video->gpu_encode_semaphore = NULL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if (video->gpu_encode_inactive) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		os_event_destroy(video->gpu_encode_inactive); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		video->gpu_encode_inactive = NULL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #define free_circlebuf(x) \ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	do { \ 
			 |