Bläddra i källkod

Request high performance mode when using x264 encoder

This should probably be reevaluated once we have
global hotkeys or other functions that would require
OBS to not be sent to sleep while in the background
without having any sort of encoder running
Palana 11 år sedan
förälder
incheckning
2deb796f49
1 ändrade filer med 15 tillägg och 8 borttagningar
  1. 15 8
      plugins/obs-x264/obs-x264.c

+ 15 - 8
plugins/obs-x264/obs-x264.c

@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <util/dstr.h>
 #include <util/darray.h>
+#include <util/platform.h>
 #include <obs-module.h>
 
 #ifndef _STDINT_H_INCLUDED
@@ -37,18 +38,20 @@
 /* ------------------------------------------------------------------------- */
 
 struct obs_x264 {
-	obs_encoder_t   encoder;
+	obs_encoder_t          encoder;
 
-	x264_param_t    params;
-	x264_t          *context;
+	x264_param_t           params;
+	x264_t                 *context;
 
-	DARRAY(uint8_t) packet_data;
+	DARRAY(uint8_t)        packet_data;
 
-	uint8_t         *extra_data;
-	uint8_t         *sei;
+	uint8_t                *extra_data;
+	uint8_t                *sei;
 
-	size_t          extra_data_size;
-	size_t          sei_size;
+	size_t                 extra_data_size;
+	size_t                 sei_size;
+
+	os_performance_token_t performance_token;
 };
 
 /* ------------------------------------------------------------------------- */
@@ -78,6 +81,7 @@ static void obs_x264_destroy(void *data)
 	struct obs_x264 *obsx264 = data;
 
 	if (obsx264) {
+		os_end_high_performance(obsx264->performance_token);
 		clear_data(obsx264);
 		da_free(obsx264->packet_data);
 		bfree(obsx264);
@@ -401,6 +405,9 @@ static void *obs_x264_create(obs_data_t settings, obs_encoder_t encoder)
 		return NULL;
 	}
 
+	obsx264->performance_token =
+		os_request_high_performance("x264 encoding");
+
 	return obsx264;
 }