/
/
/
1"""Constants for snapcast provider."""
2
3import pathlib
4
5from music_assistant_models.enums import ContentType
6from music_assistant_models.media_items.audio_format import AudioFormat
7
8from music_assistant.constants import create_sample_rates_config_entry
9
10CONF_SERVER_HOST = "snapcast_server_host"
11CONF_SERVER_CONTROL_PORT = "snapcast_server_control_port"
12CONF_USE_EXTERNAL_SERVER = "snapcast_use_external_server"
13CONF_SERVER_BUFFER_SIZE = "snapcast_server_built_in_buffer_size"
14CONF_SERVER_CHUNK_MS = "snapcast_server_built_in_chunk_ms"
15CONF_SERVER_INITIAL_VOLUME = "snapcast_server_built_in_initial_volume"
16CONF_SERVER_TRANSPORT_CODEC = "snapcast_server_built_in_codec"
17CONF_SERVER_SEND_AUDIO_TO_MUTED = "snapcast_server_built_in_send_muted"
18CONF_STREAM_IDLE_THRESHOLD = "snapcast_stream_idle_threshold"
19
20
21CONF_CATEGORY_GENERIC = "generic"
22CONF_CATEGORY_BUILT_IN = "Built-in Snapserver Settings"
23
24CONF_HELP_LINK = (
25 "https://raw.githubusercontent.com/badaix/snapcast/refs/heads/master/server/etc/snapserver.conf"
26)
27
28# snapcast has fixed sample rate/bit depth so make this config entry static and hidden
29CONF_ENTRY_SAMPLE_RATES_SNAPCAST = create_sample_rates_config_entry(
30 supported_sample_rates=[48000], supported_bit_depths=[16], hidden=True
31)
32
33DEFAULT_SNAPSERVER_IP = "127.0.0.1"
34DEFAULT_SNAPSERVER_PORT = 1705
35DEFAULT_SNAPSTREAM_IDLE_THRESHOLD = 60000
36DEFAULT_SNAPSERVER_PLUGIN_DIR = "/usr/share/snapserver/plug-ins"
37DEFAULT_SNAPSERVER_CONFIG_FILE = "/etc/snapserver.conf"
38SHIPPED_SNAPSERVER_CONFIG_FILE = (
39 pathlib.Path(__file__).parent / "snapserver" / "snapserver.conf"
40).resolve()
41
42# Socket path template for control script communication
43# The {queue_id} placeholder will be replaced with the actual queue ID
44CONTROL_SOCKET_PATH_TEMPLATE = "/tmp/ma-snapcast-{queue_id}.sock" # noqa: S108
45
46MASS_STREAM_PREFIX = "Music Assistant - "
47MASS_ANNOUNCEMENT_POSTFIX = " (announcement)"
48SNAPWEB_DIR = pathlib.Path(__file__).parent.resolve().joinpath("snapweb")
49CONTROL_SCRIPT = pathlib.Path(__file__).parent.resolve().joinpath("control.py")
50
51DEFAULT_SNAPCAST_FORMAT = AudioFormat(
52 content_type=ContentType.PCM_S16LE,
53 sample_rate=48000,
54 # TODO: we can also use 32 bits here
55 bit_depth=16,
56 channels=2,
57)
58
59DEFAULT_SNAPCAST_PCM_FORMAT = AudioFormat(
60 # the format that is used as intermediate pcm stream,
61 # we prefer F32 here to account for volume normalization
62 content_type=ContentType.PCM_F32LE,
63 sample_rate=48000,
64 bit_depth=16,
65 channels=2,
66)
67