🐛[bugfix] Model: overlay | setOverlayRawの処理を200回繰り返すとOverlayError_RequestFailedが発生するため、Overlayの再起動処理を追加

This commit is contained in:
misyaguziya
2024-09-12 23:11:20 +09:00
parent 39f3c5a84e
commit d0c3e6dd1c

View File

@@ -1,3 +1,4 @@
import os
import ctypes
import time
from psutil import process_iter
@@ -91,7 +92,7 @@ class Overlay:
self.system = openvr.init(openvr.VRApplication_Background)
self.overlay = openvr.IVROverlay()
self.overlay_system = openvr.IVRSystem()
self.handle = self.overlay.createOverlay("Overlay_Speaker2log", "SOverlay_Speaker2log_UI")
self.handle = self.overlay.createOverlay("Overlay_Speaker2log", "Overlay_Speaker2log_UI")
self.overlay.showOverlay(self.handle)
self.initialized = True
@@ -116,6 +117,15 @@ class Overlay:
width, height = img.size
img = img.tobytes()
img = (ctypes.c_char * len(img)).from_buffer_copy(img)
try:
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
except Exception as e:
printLog("error:Could not update image", e)
self.initialized = False
self.reStartOverlay()
while self.initialized is False:
time.sleep(0.1)
self.overlay.setOverlayRaw(self.handle, img, width, height, 4)
self.updateOpacity(self.settings["opacity"])
self.lastUpdate = time.monotonic()
@@ -253,6 +263,10 @@ class Overlay:
self.system = None
self.initialized = False
def reStartOverlay(self):
self.shutdownOverlay()
self.startOverlay()
@staticmethod
def checkSteamvrRunning() -> bool:
_proc_name = "vrmonitor.exe" if os.name == "nt" else "vrmonitor"