From: Marcel van der Veldt Date: Sat, 2 Jul 2022 21:34:23 +0000 (+0200) Subject: do not poll player when not needed X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=a66bddace1fe776236f27ddf0d30cf054a0a4b22;p=music-assistant-server.git do not poll player when not needed --- diff --git a/music_assistant/controllers/players.py b/music_assistant/controllers/players.py index 2ac4b371..b7e6f344 100755 --- a/music_assistant/controllers/players.py +++ b/music_assistant/controllers/players.py @@ -96,9 +96,15 @@ class PlayerController: cur_tick = 0 while True: for player in self.players: - if cur_tick == interval or player.state in ( - PlayerState.PLAYING, - PlayerState.PAUSED, + if not player.available: + continue + if cur_tick == interval or ( + player.active_queue.active + and player.state + in ( + PlayerState.PLAYING, + PlayerState.PAUSED, + ) ): player.update_state() if cur_tick == interval: diff --git a/music_assistant/models/player_queue.py b/music_assistant/models/player_queue.py index 800b6fac..c8b21051 100644 --- a/music_assistant/models/player_queue.py +++ b/music_assistant/models/player_queue.py @@ -105,10 +105,12 @@ class PlayerQueue: @property def active(self) -> bool: - """Return bool if the queue is currenty active on the player.""" - if not self.player.current_url: - return False + """Return if the queue is currenty active.""" if stream := self.stream: + if not self.stream.done.is_set(): + return True + if not self.player.current_url: + return False return stream.stream_id in self.player.current_url return False