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

The changes that the Snapcast rows and the group sheet make on a server: volume and mute of a group and of its clients, the latency and the name of a client, the stream of a group, and the members of a group. More...

Collaboration diagram for de.yaacc.snapcast.ui.SnapcastControls:
Collaboration graph

Classes

enum  Action
 What the user did. More...
 
interface  Change
 One change that can throw what the library throws. More...
 
class  Failure
 Why a change did not happen.
 
interface  Links
 Where the link of a server comes from (the receivers); null when there is none. More...
 
interface  Reporter
 Told, on the worker thread, when a change failed. More...
 

Public Member Functions

 SnapcastControls (Links links, Executor actions, Executor volumes, MonotonicClock clock, Reporter reporter)
 
 SnapcastControls (Links links, Executor actions, Executor volumes, MonotonicClock clock, Reporter reporter, SnapcastClientRemoval.OwnSource own)
 
void beginGroupGesture (ServerKey key, String groupId)
 The finger goes down on the group slider: the next value starts from the levels the members have now.
 
void setGroupVolume (final ServerKey key, final String groupId, int percent)
 Sets the volume of a group (0 to 100).
 
void setGroupMuted (final ServerKey key, final String groupId, final boolean muted)
 Mutes or unmutes a group.
 
void setGroupStream (final ServerKey key, final String groupId, final String streamId)
 The group plays this stream.
 
void setClientVolume (final ServerKey key, final String clientId, int percent)
 Sets the volume of a client (0 to 100); its mute flag is kept.
 
void setClientMuted (final ServerKey key, final String clientId, final boolean muted)
 Mutes or unmutes a client; its volume is kept.
 
void setClientLatency (final ServerKey key, final String clientId, final int latencyMs)
 Sets the latency of a client in milliseconds (the server's range is 0 to 10,000).
 
void renameClient (final ServerKey key, final String clientId, String name)
 Renames a client; the name is cleaned first, an empty one resets the name.
 
void deleteOfflineClient (final ServerKey key, final String clientId)
 Removes an offline client from the server's list (Server.DeleteClient).
 
void changeMembers (final ServerKey key, final String groupId, SnapcastLinkChoices.Change change)
 The change the link sheet made: some clients join the group, some members leave it, in one Group.SetClients call that carries the exact member list.
 

Static Public Attributes

static final long GESTURE_GAP_MILLIS = 2_000L
 A pause between two volume values that starts a new gesture.
 
static final long VOLUME_BUDGET_MILLIS = 5_000L
 The most time a gesture of the group volume may take in total.
 

Detailed Description

The changes that the Snapcast rows and the group sheet make on a server: volume and mute of a group and of its clients, the latency and the name of a client, the stream of a group, and the members of a group.

Pure Java (the Android code only forwards gestures and shows the failures).

  • Off the main thread. Every method returns at once; the calls run on one of two executors. Volume changes have an executor of their own (a gesture on a group is up to 256 calls), so they can not hold up a mute or a stream change.
  • Coalesced. While a slider is dragged only the latest value of a group or a client is sent; values that arrive while a call is in flight replace each other.
  • Start levels per gesture. The group volume moves every connected member by the same number of points from the levels it had when the gesture began (GroupVolume), so dragging back restores every member's own level. beginGroupGesture starts a gesture (the finger goes down); without it a pause of {@value GESTURE_GAP_MILLIS} ms starts a new one (a keyboard or D-pad change). A gesture has an overall budget of {@value VOLUME_BUDGET_MILLIS} ms, so a server that answers slowly can not keep the executor.
  • Failures are reported once to the Reporter as a Failure: a kind, and for a refusal of the server the reason as cleaned and shortened text. Nothing else of what the server says reaches the user, nothing is logged. A change always works on the model as it is now (the group and the clients are looked up by id when the call runs), never on a copy taken earlier.

Member Function Documentation

◆ changeMembers()

void de.yaacc.snapcast.ui.SnapcastControls.changeMembers ( final ServerKey key,
final String groupId,
SnapcastLinkChoices.Change change )

The change the link sheet made: some clients join the group, some members leave it, in one Group.SetClients call that carries the exact member list.

The list is computed from a fresh status (see below), so a client that another controller added since the sheet was opened normally stays (when the read is refused by the rate limit or fails, the cached model decides and such a client can be dropped), and an id to add that the status does not know (the client was deleted meanwhile) is left out; nothing is sent when the change leaves the members as they are; a change that would leave the group without a client is refused (NOT_POSSIBLE), because an empty list dissolves the group. Clients that leave get a group of their own on the server, so none is left without one.

Here is the call graph for this function:

◆ deleteOfflineClient()

void de.yaacc.snapcast.ui.SnapcastControls.deleteOfflineClient ( final ServerKey key,
final String clientId )

Removes an offline client from the server's list (Server.DeleteClient).

The decision is made on the server's answer, not on the model: a fresh Server.GetStatus is read right before (a real read, not the model that the rate limit would hand out; a read that fails ends the removal), and only a client that this status shows as offline, and that is not the client of this phone's own running session (SnapcastClientRemoval), is deleted, with the exact id of that status. The reasons it does not happen are failures of their own (CLIENT_CONNECTED, OWN_CLIENT, GONE). Returns at once; a second call for the same client while one is queued, and within {@value REMOVE_GAP_MILLIS} ms of the last one, is dropped. Nothing is logged: the id is the MAC address of a machine and the name is the server's text.

◆ setClientVolume()

void de.yaacc.snapcast.ui.SnapcastControls.setClientVolume ( final ServerKey key,
final String clientId,
int percent )

Sets the volume of a client (0 to 100); its mute flag is kept.

Only the latest value of a quick series is sent.

Here is the call graph for this function:

◆ setGroupMuted()

void de.yaacc.snapcast.ui.SnapcastControls.setGroupMuted ( final ServerKey key,
final String groupId,
final boolean muted )

Mutes or unmutes a group.

Coalesced like the volume: one wanted value per group and one queued task, the latest value wins. The app's own card of the group and the renderer's mute (a controller can send thousands of them) go through here, so a flood is one call to the server, can not grow the queue of the actions, and the two can not fight.

◆ setGroupStream()

void de.yaacc.snapcast.ui.SnapcastControls.setGroupStream ( final ServerKey key,
final String groupId,
final String streamId )

The group plays this stream.

streamId is the server's own id (from the stream picker), used for the call only.

◆ setGroupVolume()

void de.yaacc.snapcast.ui.SnapcastControls.setGroupVolume ( final ServerKey key,
final String groupId,
int percent )

Sets the volume of a group (0 to 100).

Returns at once; only the latest value of a quick series is sent.


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