Skip to content

Export session identity to the sessioncontrol hooks - #2274

Merged
mikebrady merged 1 commit into
mikebrady:developmentfrom
jslove:sessioncontrol-session-identity
Sep 4, 2026
Merged

mikebrady merged 1 commit into
mikebrady:developmentfrom
jslove:sessioncontrol-session-identity

Conversation

@jslove

@jslove jslove commented Sep 2, 2026

Copy link
Copy Markdown

command_start() and command_stop() run the sessioncontrol commands
(run_this_before_play_begins / run_this_after_play_ends) via fork and
execv of a fixed command string: no arguments, and nothing about the
session that triggered them. A hook can therefore be told that play
began, but not by whom -- which makes it impossible to distinguish
independent streams from several receivers carrying one grouped
AirPlay 2 stream.

Export the session's identity into the environment immediately before
running each hook. The child inherits it across fork/execv, so neither
the hook command string nor command_start()/command_stop() need to
change:

SPS_CLIENT_IP conn->client_ip_string
SPS_CONNECTION_NUMBER conn->connection_number
SPS_GROUP_ID conn->airplay_gid, the AirPlay 2 group UUID
from the SETUP plist ("" if none)
SPS_GROUP_CONTAINS_LEADER conn->groupContainsGroupLeader

The last two are set to ""/0 on non-AirPlay 2 builds so that a hook can
rely on all four always being present. Nothing inside shairport-sync
reads these; behaviour is unchanged for any configuration that does not
use sessioncontrol hooks.

command_start() and command_stop() run the sessioncontrol commands
(run_this_before_play_begins / run_this_after_play_ends) via fork and
execv of a fixed command string: no arguments, and nothing about the
session that triggered them. A hook can therefore be told that play
began, but not by whom -- which makes it impossible to distinguish
independent streams from several receivers carrying one grouped
AirPlay 2 stream.

Export the session's identity into the environment immediately before
running each hook. The child inherits it across fork/execv, so neither
the hook command string nor command_start()/command_stop() need to
change:

  SPS_CLIENT_IP              conn->client_ip_string
  SPS_CONNECTION_NUMBER      conn->connection_number
  SPS_GROUP_ID               conn->airplay_gid, the AirPlay 2 group UUID
                             from the SETUP plist ("" if none)
  SPS_GROUP_CONTAINS_LEADER  conn->groupContainsGroupLeader

The last two are set to ""/0 on non-AirPlay 2 builds so that a hook can
rely on all four always being present. Nothing inside shairport-sync
reads these; behaviour is unchanged for any configuration that does not
use sessioncontrol hooks.
@mikebrady
mikebrady merged commit eb9668c into mikebrady:development Sep 4, 2026
@mikebrady

Copy link
Copy Markdown
Owner

This is lovely, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants