mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 05:47:30 +08:00
Opt: Stop scrcpy server during wait
This commit is contained in:
parent
49606b7868
commit
37e0d70e0d
4
alas.py
4
alas.py
@ -424,6 +424,7 @@ class AzurLaneAutoScript:
|
||||
logger.info('Close game during wait')
|
||||
self.device.app_stop()
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
if not self.wait_until(task.next_run):
|
||||
del self.__dict__['config']
|
||||
continue
|
||||
@ -432,18 +433,21 @@ class AzurLaneAutoScript:
|
||||
logger.info('Goto main page during wait')
|
||||
self.run('goto_main')
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
if not self.wait_until(task.next_run):
|
||||
del self.__dict__['config']
|
||||
continue
|
||||
elif method == 'stay_there':
|
||||
logger.info('Stay there during wait')
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
if not self.wait_until(task.next_run):
|
||||
del self.__dict__['config']
|
||||
continue
|
||||
else:
|
||||
logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there')
|
||||
release_resources()
|
||||
self.device.release_during_wait()
|
||||
if not self.wait_until(task.next_run):
|
||||
del self.__dict__['config']
|
||||
continue
|
||||
|
@ -65,6 +65,12 @@ class Device(Screenshot, Control, AppControl, EmulatorManager):
|
||||
|
||||
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):
|
||||
self.detect_record.add(str(button))
|
||||
|
||||
|
@ -146,9 +146,9 @@ class ScrcpyCore(Connection):
|
||||
Stop listening (both threaded and blocked)
|
||||
"""
|
||||
logger.hr('Scrcpy server stop')
|
||||
err = self._scrcpy_receive_from_server_stream()
|
||||
if err:
|
||||
logger.error(err)
|
||||
# err = self._scrcpy_receive_from_server_stream()
|
||||
# if err:
|
||||
# logger.error(err)
|
||||
|
||||
self._scrcpy_alive = False
|
||||
if self._scrcpy_server_stream is not None:
|
||||
@ -169,6 +169,8 @@ class ScrcpyCore(Connection):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
logger.info('Scrcpy server stopped')
|
||||
|
||||
def _scrcpy_receive_from_server_stream(self):
|
||||
if self._scrcpy_server_stream is not None:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user