Remove concurrent heartbeat pings on the same MPD client
- idle() and periodic ping() on one connection can cause churn/wakeups - Normalized mixrampdb == "nan" to 0
This commit is contained in:
parent
897cb383eb
commit
9b910cd991
2 changed files with 4 additions and 8 deletions
|
|
@ -17,10 +17,13 @@ def to_queue(mpd: MpdState) -> Queue:
|
|||
|
||||
def to_mixramp(mpd: MpdState) -> MixRamp:
|
||||
delay = mpd.status.get("mixrampdelay", 0)
|
||||
db = mpd.status.get("mixrampdb", 0)
|
||||
if delay == "nan":
|
||||
delay = 0
|
||||
if db == "nan":
|
||||
db = 0
|
||||
return MixRamp(
|
||||
db=float(mpd.status.get("mixrampdb", 0)),
|
||||
db=float(db),
|
||||
delay=float(delay),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from ..playback import Playback
|
|||
from ..playback.state import PlaybackState
|
||||
from ..player import Player
|
||||
from ..song_receiver import Receiver
|
||||
from ..tools.asyncio import run_background_task
|
||||
from .artwork_cache import MpdArtworkCache
|
||||
from .convert.to_playback import to_playback
|
||||
from .types import MpdState
|
||||
|
|
@ -42,12 +41,6 @@ class MpdStateListener(Player):
|
|||
print("Authorising to MPD with your password...")
|
||||
await self.client.password(conf.password.get_secret_value())
|
||||
print(f"Connected to MPD v{self.client.mpd_version}")
|
||||
run_background_task(self.heartbeat())
|
||||
|
||||
async def heartbeat(self) -> None:
|
||||
while True:
|
||||
await self.client.ping()
|
||||
await asyncio.sleep(10)
|
||||
|
||||
async def refresh(self) -> None:
|
||||
await self.update_receivers()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue