/
/
/
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
36
37# Socket path template for control script communication
38# The {queue_id} placeholder will be replaced with the actual queue ID
39CONTROL_SOCKET_PATH_TEMPLATE = "/tmp/ma-snapcast-{queue_id}.sock" # noqa: S108
40
41MASS_STREAM_PREFIX = "Music Assistant - "
42MASS_ANNOUNCEMENT_POSTFIX = " (announcement)"
43SNAPWEB_DIR = pathlib.Path(__file__).parent.resolve().joinpath("snapweb")
44CONTROL_SCRIPT = pathlib.Path(__file__).parent.resolve().joinpath("control.py")
45
46DEFAULT_SNAPCAST_FORMAT = AudioFormat(
47 content_type=ContentType.PCM_S16LE,
48 sample_rate=48000,
49 # TODO: we can also use 32 bits here
50 bit_depth=16,
51 channels=2,
52)
53
54DEFAULT_SNAPCAST_PCM_FORMAT = AudioFormat(
55 # the format that is used as intermediate pcm stream,
56 # we prefer F32 here to account for volume normalization
57 content_type=ContentType.PCM_F32LE,
58 sample_rate=48000,
59 bit_depth=16,
60 channels=2,
61)
62