@@ -115,28 +115,23 @@ def list2(self) -> t.List[DataLDPlayerInfo]:
115115 return out
116116
117117
118- IScreenShotClassDtorType = ctypes .WINFUNCTYPE (None , ctypes .c_int32 )
119- IScreenShotClassCapType = ctypes .WINFUNCTYPE (ctypes .c_void_p )
120- IScreenShotClassReleaseType = ctypes .WINFUNCTYPE (None )
121- IScreenShotClass_Dtor = IScreenShotClassDtorType (0 , "IScreenShotClass_Dtor" )
122- IScreenShotClass_Cap = IScreenShotClassCapType (1 , "IScreenShotClass_Cap" )
123- IScreenShotClass_Release = IScreenShotClassReleaseType (2 , "IScreenShotClass_Release" )
124-
125- CreateScreenshotInstanceType = ctypes .WINFUNCTYPE (ctypes .c_void_p , ctypes .c_uint , ctypes .c_uint )
126-
127-
128118class IScreenShotClass :
129119 def __init__ (self , ptr ):
130120 self .ptr = ptr
121+
122+ # Define in class since ctypes.WINFUNCTYPE is windows only
123+ cap_type = ctypes .WINFUNCTYPE (ctypes .c_void_p )
124+ release_type = ctypes .WINFUNCTYPE (None )
125+ self .class_cap = cap_type (1 , "IScreenShotClass_Cap" )
131126 # Keep reference count
132127 # so __del__ won't have an empty IScreenShotClass_Cap
133- self .release = IScreenShotClass_Release
128+ self .class_release = release_type ( 2 , " IScreenShotClass_Release" )
134129
135130 def cap (self ):
136- return IScreenShotClass_Cap (self .ptr )
131+ return self . class_cap (self .ptr )
137132
138133 def __del__ (self ):
139- self .release (self .ptr )
134+ self .class_release (self .ptr )
140135
141136
142137def retry (func ):
@@ -189,8 +184,8 @@ def __init__(self, ld_folder: str, instance_id: int):
189184 ldopengl_dll = os .path .abspath (os .path .join (ld_folder , './ldopengl64.dll' ))
190185 logger .info (
191186 f'LDOpenGL init, '
192- f'nemu_folder ={ ld_folder } , '
193- f'ipc_dll ={ ldopengl_dll } , '
187+ f'ld_folder ={ ld_folder } , '
188+ f'ldopengl_dll ={ ldopengl_dll } , '
194189 f'instance_id={ instance_id } '
195190 )
196191 self .console = LDConsole (ld_folder )
@@ -332,10 +327,10 @@ def screenshot_ldopengl(self):
332327
333328
334329if __name__ == '__main__' :
335- self = LDOpenGLImpl ('E:/ProgramFiles/LDPlayer9' , instance_id = 1 )
330+ ld = LDOpenGLImpl ('E:/ProgramFiles/LDPlayer9' , instance_id = 1 )
336331 for _ in range (5 ):
337332 import time
338333
339334 start = time .time ()
340- self .screenshot ()
335+ ld .screenshot ()
341336 print (time .time () - start )
0 commit comments