YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.snapcast.SnapcastRendererOutput Class Reference

The output of the YAACC renderer (task 9.1), decided without Android. More...

Collaboration diagram for de.yaacc.snapcast.SnapcastRendererOutput:
Collaboration graph

Classes

enum  Content
 What the content is, judged by its types. More...
 
class  Decision
 The answer for one play.
 
enum  GroupFacts
 What the model of the servers knows about the chosen group. More...
 
enum  Mode
 What the renderer plays on. More...
 
enum  Output
 Where a play goes. More...
 
interface  Probe
 The live facts of the app: the model of the servers and the wake of a connection. More...
 
enum  Problem
 What is wrong, or to be said. More...
 
class  Setting
 The two preferences, validated.
 
interface  StringSource
 Reads a preference as text; null for none. More...
 
class  UnreachableMemory
 Remembers for a few seconds that the server of a group did not answer, so that a flood of plays (the wait of up to 4 s is inside the transport's state-machine lock) is refused at once instead of costing the wait every time and waking the connection again and again.
 
interface  Waiter
 A clock and a sleep, injectable so that the tests do not wait. More...
 

Static Public Member Functions

static Setting read (StringSource source)
 Reads the setting.
 
static boolean isValidSendspinTarget (String id)
 True for the receiver id of a Sendspin player: it starts with sendspin, is at most 200 characters long and has no control character.
 
static boolean isCanonicalGroupId (String id)
 True for a receiver id that parses from the right and prints back to the same text.
 
static Content contentOf (java.util.List< String > mimeTypes)
 What the content is, from the types of its items (null or empty types are "unknown"): video or image, or a type that is not audio, is Content#NOT_MUSIC (a group plays music only; checked first); else an item without a type makes the content Content#UNKNOWN_TYPE; else Content#PLAYABLE.
 
static boolean isStale (String createdKey, Setting now)
 True when a player made for createdKey is not for the output the setting says now (it was switched meanwhile).
 
static Decision decide (Setting setting, boolean contentRefused, GroupFacts facts)
 As decide(Setting, Content, GroupFacts) for a content that is music or not.
 
static Decision decide (Setting setting, Content content, GroupFacts facts)
 The decision from the facts.
 
static GroupFacts awaitFacts (String receiverId, Probe probe, Waiter waiter, long maxWaitMillis)
 The facts of the group; while the server is pending or offline it is woken once and looked at every 200 ms until it is ready, gone, not listed, or maxWaitMillis are over.
 
static Decision resolve (Setting setting, Content content, Probe probe, Waiter waiter, long maxWaitMillis, UnreachableMemory memory)
 As resolve(Setting, Content, Probe, Waiter, long), with the memory of servers that did not answer: a play for a group that failed a moment ago is refused at once (SERVER_UNREACHABLE) without asking or waking anything.
 
static Decision resolve (Setting setting, boolean contentRefused, Probe probe, Waiter waiter, long maxWaitMillis)
 As resolve(Setting, Content, Probe, Waiter, long) for a content that is music or not.
 
static Decision resolve (Setting setting, Content content, Probe probe, Waiter waiter, long maxWaitMillis)
 The decision for one play, with the wait for a connection that is coming up.
 
static String outputKey (Setting setting)
 Which output a player was made for: device or group:<id>.
 
static java.util.Set< String > withRendererGroup (java.util.Collection< String > selection, Setting setting)
 The receiver ids whose servers must be remembered: the selected receivers, and the chosen group of the renderer while the output is the group (so the server is known after a restart without a scan, as for a selected group; with the output back on this device it is forgotten again).
 

Static Public Attributes

static final String KEY_OUTPUT = "settings_renderer_output"
 The preference that holds the output (VALUE_DEVICE or VALUE_GROUP).
 
static final String KEY_GROUP = "settings_renderer_output_group"
 The preference that holds the receiver id of the chosen group.
 
static final String VALUE_DEVICE = "device"
 This device: the default.
 
static final String VALUE_GROUP = "group"
 A Snapcast group.
 
static final String VALUE_SENDSPIN = "sendspin"
 A Sendspin player, or a group of players that this phone's hub leads (owner, 2026-11-30).
 
static final String KEY_SENDSPIN = "settings_renderer_output_sendspin"
 The preference that holds the receiver id of the chosen Sendspin player or group leader.
 
static final long DEFAULT_MAX_WAIT_MILLIS = 4_000L
 How long a play waits for a server that is listed but not connected, and the length of one step.
 

Detailed Description

The output of the YAACC renderer (task 9.1), decided without Android.

The renderer plays either on this device (the default, the behaviour of before) or only into a Snapcast group: it feeds the group and the local audio output is off. This class reads the two preferences, says which output a new play uses from the live facts, and which error the controller and the user get when it can not be the group. Nothing here starts a connection; the Probe and the Waiter are the app's.

The setting. KEY_OUTPUT is device (default) or group; KEY_GROUP holds the receiver id of the chosen group (snapcast:<server key>:<group id>, see SnapcastGroupDevice#idOf), never a name. The id is validated at every read: it must parse from the right and be in the canonical form. A value that is corrupt, unknown or unreadable gives THIS_DEVICE with Setting#isDamaged() set, so the renderer plays locally and says so; it never crashes and never plays into a group it can not name exactly. Group mode with no group chosen is not damaged but an error of its own (Problem#NO_GROUP_CHOSEN): the user asked for the group, so the audio is not played on the phone instead.

Facts. GroupFacts is what the model of the servers says about the chosen group right now. A server that is listed but has no status yet, or only a status of an earlier connection, gets one wake and a short bounded wait (awaitFacts) so that a play right after the app started does not fail for a connection that is only coming up. What only the feed can know (no free stream port, a name conflict, a server that refuses the stream, a busy slot) is not guessed here: it comes back from the feed as its typed error.

Member Function Documentation

◆ awaitFacts()

static GroupFacts de.yaacc.snapcast.SnapcastRendererOutput.awaitFacts ( String receiverId,
Probe probe,
Waiter waiter,
long maxWaitMillis )
static

The facts of the group; while the server is pending or offline it is woken once and looked at every 200 ms until it is ready, gone, not listed, or maxWaitMillis are over.

The last facts are returned (the error follows from them). An interrupt ends the wait at once and keeps the interrupt flag.

Referenced by de.yaacc.snapcast.SnapcastRendererOutput.resolve(), and de.yaacc.snapcast.SnapcastRendererOutput.resolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contentOf()

static Content de.yaacc.snapcast.SnapcastRendererOutput.contentOf ( java.util.List< String > mimeTypes)
static

What the content is, from the types of its items (null or empty types are "unknown"): video or image, or a type that is not audio, is Content#NOT_MUSIC (a group plays music only; checked first); else an item without a type makes the content Content#UNKNOWN_TYPE; else Content#PLAYABLE.

No items at all is unknown.

◆ decide()

static Decision de.yaacc.snapcast.SnapcastRendererOutput.decide ( Setting setting,
Content content,
GroupFacts facts )
static

The decision from the facts.

Parameters
contentwhat the content is; refused in group mode unless it is music
factswhat the model says about the group; not looked at unless the mode is group with a group chosen and the content is music; a missing fact never plays (it counts as pending)

◆ isValidSendspinTarget()

static boolean de.yaacc.snapcast.SnapcastRendererOutput.isValidSendspinTarget ( String id)
static

True for the receiver id of a Sendspin player: it starts with sendspin, is at most 200 characters long and has no control character.

The hub knows what is a player; this only keeps a damaged preference out.

Referenced by de.yaacc.snapcast.SnapcastRendererOutput.read().

Here is the caller graph for this function:

◆ outputKey()

static String de.yaacc.snapcast.SnapcastRendererOutput.outputKey ( Setting setting)
static

Which output a player was made for: device or group:<id>.

A damaged setting plays locally, so its key is device. Two players with the same key are for the same output; a change of the setting stops the others.

Referenced by de.yaacc.snapcast.SnapcastRendererOutput.isStale().

Here is the caller graph for this function:

◆ read()

static Setting de.yaacc.snapcast.SnapcastRendererOutput.read ( StringSource source)
static

Reads the setting.

Never throws.

Parameters
sourcethe preferences; null or a source that fails counts as damaged

Referenced by de.yaacc.upnp.server.renderingcontrol.RendererVolumes.forContext(), de.yaacc.upnp.server.openhome.RendererOutputSources.select(), and de.yaacc.upnp.server.openhome.RendererOutputSources.snapshot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolve() [1/2]

static Decision de.yaacc.snapcast.SnapcastRendererOutput.resolve ( Setting setting,
Content content,
Probe probe,
Waiter waiter,
long maxWaitMillis )
static

The decision for one play, with the wait for a connection that is coming up.

The server is asked only in group mode with a group chosen and music content: this device never touches the network here.

Here is the call graph for this function:

◆ resolve() [2/2]

static Decision de.yaacc.snapcast.SnapcastRendererOutput.resolve ( Setting setting,
Content content,
Probe probe,
Waiter waiter,
long maxWaitMillis,
UnreachableMemory memory )
static

As resolve(Setting, Content, Probe, Waiter, long), with the memory of servers that did not answer: a play for a group that failed a moment ago is refused at once (SERVER_UNREACHABLE) without asking or waking anything.

Parameters
memorymay be null (nothing is remembered)

Referenced by de.yaacc.snapcast.SnapcastRendererOutput.resolve(), and de.yaacc.snapcast.SnapcastRendererOutput.resolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withRendererGroup()

static java.util.Set< String > de.yaacc.snapcast.SnapcastRendererOutput.withRendererGroup ( java.util.Collection< String > selection,
Setting setting )
static

The receiver ids whose servers must be remembered: the selected receivers, and the chosen group of the renderer while the output is the group (so the server is known after a restart without a scan, as for a selected group; with the output back on this device it is forgotten again).

A new set; the arguments are not changed.


The documentation for this class was generated from the following file: