/
/
/
1"""Constants for the Squeezelite player provider."""
2
3from __future__ import annotations
4
5from dataclasses import dataclass
6
7from aioslimproto.client import PlayerState as SlimPlayerState
8from aioslimproto.models import VisualisationType as SlimVisualisationType
9from music_assistant_models.config_entries import ConfigEntry, ConfigValueOption
10from music_assistant_models.enums import ConfigEntryType, PlaybackState, RepeatMode
11
12CONF_CLI_TELNET_PORT = "cli_telnet_port"
13CONF_CLI_JSON_PORT = "cli_json_port"
14CONF_DISCOVERY = "discovery"
15CONF_PORT = "port"
16DEFAULT_SLIMPROTO_PORT = 3483
17CONF_DISPLAY = "display"
18CONF_VISUALIZATION = "visualization"
19
20DEFAULT_PLAYER_VOLUME = 20
21DEFAULT_VISUALIZATION = SlimVisualisationType.NONE
22
23# sync constants
24MIN_DEVIATION_ADJUST = 8 # 5 milliseconds
25MIN_REQ_PLAYPOINTS = 8 # we need at least 8 measurements
26DEVIATION_JUMP_IGNORE = 500 # ignore a sudden unrealistic jump
27MAX_SKIP_AHEAD_MS = 800 # 0.8 seconds
28
29STATE_MAP = {
30 SlimPlayerState.BUFFERING: PlaybackState.PLAYING,
31 SlimPlayerState.BUFFER_READY: PlaybackState.PLAYING,
32 SlimPlayerState.PAUSED: PlaybackState.PAUSED,
33 SlimPlayerState.PLAYING: PlaybackState.PLAYING,
34 SlimPlayerState.STOPPED: PlaybackState.IDLE,
35}
36
37REPEATMODE_MAP = {RepeatMode.OFF: 0, RepeatMode.ONE: 1, RepeatMode.ALL: 2}
38
39CONF_ENTRY_DISPLAY = ConfigEntry(
40 key=CONF_DISPLAY,
41 type=ConfigEntryType.BOOLEAN,
42 default_value=False,
43 required=False,
44 label="Enable display support",
45 description="Enable/disable native display support on squeezebox or squeezelite32 hardware.",
46 advanced=True,
47)
48CONF_ENTRY_VISUALIZATION = ConfigEntry(
49 key=CONF_VISUALIZATION,
50 type=ConfigEntryType.STRING,
51 default_value=DEFAULT_VISUALIZATION,
52 options=[
53 ConfigValueOption(title=x.name.replace("_", " ").title(), value=x.value)
54 for x in SlimVisualisationType
55 ],
56 required=False,
57 label="Visualization type",
58 description="The type of visualization to show on the display "
59 "during playback if the device supports this.",
60 advanced=True,
61 depends_on=CONF_DISPLAY,
62)
63
64
65@dataclass
66class SyncPlayPoint:
67 """Simple structure to describe a Sync Playpoint."""
68
69 timestamp: float
70 sync_master: str
71 diff: int
72