mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-25 15:58:14 +08:00
Opt: Stop scrcpy server during wait
This commit is contained in:
4
alas.py
4
alas.py
@@ -424,6 +424,7 @@ class AzurLaneAutoScript:
|
|||||||
logger.info('Close game during wait')
|
logger.info('Close game during wait')
|
||||||
self.device.app_stop()
|
self.device.app_stop()
|
||||||
release_resources()
|
release_resources()
|
||||||
|
self.device.release_during_wait()
|
||||||
if not self.wait_until(task.next_run):
|
if not self.wait_until(task.next_run):
|
||||||
del self.__dict__['config']
|
del self.__dict__['config']
|
||||||
continue
|
continue
|
||||||
@@ -432,18 +433,21 @@ class AzurLaneAutoScript:
|
|||||||
logger.info('Goto main page during wait')
|
logger.info('Goto main page during wait')
|
||||||
self.run('goto_main')
|
self.run('goto_main')
|
||||||
release_resources()
|
release_resources()
|
||||||
|
self.device.release_during_wait()
|
||||||
if not self.wait_until(task.next_run):
|
if not self.wait_until(task.next_run):
|
||||||
del self.__dict__['config']
|
del self.__dict__['config']
|
||||||
continue
|
continue
|
||||||
elif method == 'stay_there':
|
elif method == 'stay_there':
|
||||||
logger.info('Stay there during wait')
|
logger.info('Stay there during wait')
|
||||||
release_resources()
|
release_resources()
|
||||||
|
self.device.release_during_wait()
|
||||||
if not self.wait_until(task.next_run):
|
if not self.wait_until(task.next_run):
|
||||||
del self.__dict__['config']
|
del self.__dict__['config']
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there')
|
logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there')
|
||||||
release_resources()
|
release_resources()
|
||||||
|
self.device.release_during_wait()
|
||||||
if not self.wait_until(task.next_run):
|
if not self.wait_until(task.next_run):
|
||||||
del self.__dict__['config']
|
del self.__dict__['config']
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ class Device(Screenshot, Control, AppControl, EmulatorManager):
|
|||||||
|
|
||||||
return self.image
|
return self.image
|
||||||
|
|
||||||
|
def release_during_wait(self):
|
||||||
|
# Scrcpy server is still sending video stream,
|
||||||
|
# stop it during wait
|
||||||
|
if self.config.Emulator_ScreenshotMethod == 'scrcpy':
|
||||||
|
self._scrcpy_server_stop()
|
||||||
|
|
||||||
def stuck_record_add(self, button):
|
def stuck_record_add(self, button):
|
||||||
self.detect_record.add(str(button))
|
self.detect_record.add(str(button))
|
||||||
|
|
||||||
|
|||||||
@@ -146,9 +146,9 @@ class ScrcpyCore(Connection):
|
|||||||
Stop listening (both threaded and blocked)
|
Stop listening (both threaded and blocked)
|
||||||
"""
|
"""
|
||||||
logger.hr('Scrcpy server stop')
|
logger.hr('Scrcpy server stop')
|
||||||
err = self._scrcpy_receive_from_server_stream()
|
# err = self._scrcpy_receive_from_server_stream()
|
||||||
if err:
|
# if err:
|
||||||
logger.error(err)
|
# logger.error(err)
|
||||||
|
|
||||||
self._scrcpy_alive = False
|
self._scrcpy_alive = False
|
||||||
if self._scrcpy_server_stream is not None:
|
if self._scrcpy_server_stream is not None:
|
||||||
@@ -169,6 +169,8 @@ class ScrcpyCore(Connection):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
logger.info('Scrcpy server stopped')
|
||||||
|
|
||||||
def _scrcpy_receive_from_server_stream(self):
|
def _scrcpy_receive_from_server_stream(self):
|
||||||
if self._scrcpy_server_stream is not None:
|
if self._scrcpy_server_stream is not None:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user