Change order of shutdown to shorten audio gap

This commit is contained in:
Matthew Stratford 2021-09-02 00:10:32 +01:00
parent be1855236a
commit e3854b5248

View file

@ -242,15 +242,19 @@ class BAPSicleServer:
self.websockets_server.join(timeout=PROCESS_KILL_TIMEOUT_S) self.websockets_server.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.websockets_server del self.websockets_server
print("Stopping Players") print("Stopping File Manager")
for q in self.player_to_q: if self.file_manager:
q.put("ALL:QUIT") self.file_manager.terminate()
self.file_manager.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.file_manager
for player in self.player: print("Stopping Controllers")
player.join(timeout=PROCESS_KILL_TIMEOUT_S) if self.controller_handler:
self.controller_handler.terminate()
del self.player self.controller_handler.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.controller_handler
# Stop the Webserver late as we can to allow Presenter to pull images for the disconnection page if it needs to.
print("Stopping Web Server") print("Stopping Web Server")
if self.webserver: if self.webserver:
self.webserver.terminate() self.webserver.terminate()
@ -263,17 +267,16 @@ class BAPSicleServer:
self.player_handler.join(timeout=PROCESS_KILL_TIMEOUT_S) self.player_handler.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.player_handler del self.player_handler
print("Stopping File Manager") # Now we've stopped everything else, now is the time to stop the players. This is to keep playing for as long as possible during a restart.
if self.file_manager: print("Stopping Players")
self.file_manager.terminate() for q in self.player_to_q:
self.file_manager.join(timeout=PROCESS_KILL_TIMEOUT_S) q.put("ALL:QUIT")
del self.file_manager
for player in self.player:
player.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.player
print("Stopping Controllers")
if self.controller_handler:
self.controller_handler.terminate()
self.controller_handler.join(timeout=PROCESS_KILL_TIMEOUT_S)
del self.controller_handler
print("Stopped all processes.") print("Stopped all processes.")