One connected snapclient. Owns the TCP socket, speaks the snapcast protocol, and writes the audio chunks the stream hands it.
On Hello it replies with ServerSettings and registers with Snapcast.Server. The
server then assigns the active stream and sends that stream's CodecHeader exactly
once (PCM via set_format/3, FLAC via the stream's attach) — the equivalent of
snapserver's send(stream->getHeader()). A connecting client therefore receives one
codec header for the stream it will play (or none while idle), not a default header
followed by the real one. It answers Time requests for clock sync and tracks the
client's volume/mute from ClientInfo.
Summary
Functions
Start reading from the socket (after the acceptor transfers ownership).
Returns a specification to start this module under a supervisor.
Write a pre-built CodecHeader frame (FLAC or Opus, framed by the stream) to the
client, unless its decoder was already built from the same {codec, format} key
(see set_format/3).
Hand a framed message to this session to write to its socket.
Re-send ServerSettings (format-scaled bufferMs) for the next stream, plus — for the
:pcm transport — the matching PCM CodecHeader. The :flac transport sends its
CodecHeader from the stream via send_codec_header/3 once it has been parsed.
Set this client's playback volume (0-100) via a fresh ServerSettings.
Functions
Start reading from the socket (after the acceptor transfers ownership).
Returns a specification to start this module under a supervisor.
See Supervisor.
Write a pre-built CodecHeader frame (FLAC or Opus, framed by the stream) to the
client, unless its decoder was already built from the same {codec, format} key
(see set_format/3).
Hand a framed message to this session to write to its socket.
Re-send ServerSettings (format-scaled bufferMs) for the next stream, plus — for the
:pcm transport — the matching PCM CodecHeader. The :flac transport sends its
CodecHeader from the stream via send_codec_header/3 once it has been parsed.
A snapclient tears down and rebuilds its decoder and player on every CodecHeader
it receives, discarding the audio buffered in both. Consecutive tracks of the same
format must therefore not re-announce: both this and send_codec_header/3 skip
the write when the client's decoder was already built from the same
{codec, format}, so an album stays gapless instead of losing its buffered tail.
force re-announces anyway: a seek or manual skip replaces a live stream, and the
client's buffered audio — now from the wrong position/track — must be flushed. For
an encoded codec it also clears the gate so the new stream's CodecHeader re-sends.
Set this client's playback volume (0-100) via a fresh ServerSettings.