Prechádzať zdrojové kódy

win-capture: Fix memory capture crash on new capture

If the target process re-creates its D3D context, the game capture tick
can trigger before the capture is setup, in which case OBS gets a
CAPTURE_RETRY message. However with the memory capture method, it
continues to try and copy from the shared memory pointer which is no
longer valid, resulting in a crash. The fix uses the old texture until
the next tick at which point the new capture should be ready for use.
Richard Stanway 8 rokov pred
rodič
commit
66ec96d52c
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  1. 6 1
      plugins/win-capture/game-capture.c

+ 6 - 1
plugins/win-capture/game-capture.c

@@ -1429,12 +1429,17 @@ static inline void copy_16bit_tex(struct game_capture *gc, int cur_texture,
 
 static void copy_shmem_tex(struct game_capture *gc)
 {
-	int cur_texture = gc->shmem_data->last_tex;
+	int cur_texture;
 	HANDLE mutex = NULL;
 	uint32_t pitch;
 	int next_texture;
 	uint8_t *data;
 
+	if (!gc->shmem_data)
+		return;
+
+	cur_texture = gc->shmem_data->last_tex;
+
 	if (cur_texture < 0 || cur_texture > 1)
 		return;