Просмотр исходного кода

Don't update video of sources if not displaying

This is a bit of an optimization to reduce load a little bit if any of
the video capture sources are not currently being displayed on the
screen.  They will simply not capture or update their texture data if
they are not currently being shown anywhere.

The mac and window game capture sources don't really apply due to the
fact that their textures aren't updated on the source's end (they update
inside of the hooks).
jp9000 11 лет назад
Родитель
Сommit
b277f2b737

+ 3 - 0
plugins/linux-capture/xcompcap-main.cpp

@@ -443,6 +443,9 @@ void XCompcapMain::tick(float seconds)
 {
 	UNUSED_PARAMETER(seconds);
 
+	if (!obs_source_showing(p->source))
+		return;
+
 	PLock lock(&p->lock, true);
 
 	if (!lock.isLocked())

+ 2 - 0
plugins/linux-capture/xshm-input.c

@@ -392,6 +392,8 @@ static void xshm_video_tick(void *vptr, float seconds)
 
 	if (!data->texture)
 		return;
+	if (!obs_source_showing(data->source))
+		return;
 
 	xcb_shm_get_image_cookie_t           img_c;
 	xcb_shm_get_image_reply_t            *img_r;

+ 2 - 0
plugins/mac-capture/mac-display-capture.m

@@ -328,6 +328,8 @@ static void display_capture_video_tick(void *data, float seconds)
 
 	if (!dc->current)
 		return;
+	if (!obs_source_showing(dc->source))
+		return;
 
 	IOSurfaceRef prev_prev = dc->prev;
 	if (pthread_mutex_lock(&dc->mutex))

+ 5 - 0
plugins/mac-capture/mac-window-capture.m

@@ -200,6 +200,11 @@ static inline void window_capture_tick_internal(struct window_capture *wc,
 
 static void window_capture_tick(void *data, float seconds)
 {
+	struct window_capture *wc = data;
+
+	if (!obs_source_showing(wc->source))
+		return;
+
 	@autoreleasepool {
 		return window_capture_tick_internal(data, seconds);
 	}

+ 3 - 0
plugins/win-capture/monitor-capture.c

@@ -143,6 +143,9 @@ static void monitor_capture_tick(void *data, float seconds)
 {
 	struct monitor_capture *capture = data;
 
+	if (!obs_source_showing(capture->source))
+		return;
+
 	obs_enter_graphics();
 	dc_capture_capture(&capture->data, NULL);
 	obs_leave_graphics();

+ 3 - 0
plugins/win-capture/window-capture.c

@@ -149,6 +149,9 @@ static void wc_tick(void *data, float seconds)
 	RECT rect;
 	bool reset_capture = false;
 
+	if (!obs_source_showing(wc->source))
+		return;
+
 	if (!wc->window || !IsWindow(wc->window)) {
 		if (!wc->title && !wc->class)
 			return;