Repository navigation
Add the identity flags: --id, --manufacturer, --product-name - #29
Conversation
There was a problem hiding this comment.
Pull request overview
Adds configurable client identity and device metadata, alongside the stacked stream-hook functionality.
Changes:
- Adds identity and device-information flags with config-file support.
- Runs asynchronous start/stop hooks with
SENDSPIN_*context. - Updates tests, build configuration, and documentation.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
CMakeLists.txt |
Builds hook implementation and tests. |
src/cli.h |
Defines identity and hook options. |
src/cli.cpp |
Parses and documents new options. |
src/hooks.h |
Declares the hook environment and runner. |
src/hooks.cpp |
Spawns, monitors, and reports hooks. |
src/log.h |
Adds the hook log category. |
src/main.cpp |
Applies identity and wires hooks. |
src/player_listener.h |
Exposes stream lifecycle callbacks. |
src/player_listener.cpp |
Emits lifecycle callbacks. |
tests/cli_test.cpp |
Tests identity flags and defaults. |
tests/config_file_test.cpp |
Tests identity configuration keys. |
tests/hooks_test.cpp |
Tests hook parsing and execution. |
README.md |
Documents identity and stream hooks. |
packaging/sendspin-cli.conf.example |
Adds example identity and hook settings. |
docs/wiki/Configuration.md |
Lists new configuration keys. |
docs/wiki/Controlling-the-Player.md |
Documents stream-hook operation. |
docs/ROADMAP.md |
Marks hooks and identity as shipped. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (outbound) { | ||
| context.server_url = outbound->dialed_url(); |
There was a problem hiding this comment.
Real, and out of this PR's scope — dialed_url_ and the on_stream_event block that reads it are #28's. Filed as #34. The docs already point a hook that must be certain at SENDSPIN_SERVER_ID, but as the issue says, that is a hedge rather than a fix: closing it properly needs sendspin-cpp to name the live connection's origin.
| dup2(STDERR_FILENO, STDOUT_FILENO); | ||
| execve("/bin/sh", argv, envp.data()); |
There was a problem hiding this comment.
Already fixed on main by 010959b ("Hand a hook nothing of the player's but the two output streams"), which closes every descriptor above stderr in the child and puts SIGPIPE back to SIG_DFL. This branch was stacked on #28's first commit only and so carried a stale copy; it is now rebased onto main and no longer touches src/hooks.cpp at all.
| cli_log(LogLevel::DEBUG, "Running %s hook [%d]: %s", event, static_cast<int>(pid), | ||
| command.c_str()); | ||
| this->running_.push_back({pid, event, command}); |
| std::fprintf(out, " player's volume, group and pairing under -- -n is only\n"); | ||
| std::fprintf(out, " what it displays. Defaults to an id derived from the\n"); | ||
| std::fprintf(out, " network interface MAC, which two players on one host\n"); | ||
| std::fprintf(out, " would share: give each its own --id (and --port)\n"); |
There was a problem hiding this comment.
Fixed. --help now reads "give each its own --id (and its own --port and --state-dir)", which is what packaging/sendspin-cli.conf.example and the comment at src/state_store.cpp:234 already said — this makes the three agree.
| each server-side setting lands on whichever connected last. A dual-mono pair needs | ||
| `--id` (and `--port`) per instance. Run `--help` for the current state of each |
There was a problem hiding this comment.
Fixed, the same way as the --help text. The README also now names --id in the four other passages that enumerate what a second player on one host needs (the state-file section here, and the wiki's Configuration, Troubleshooting and Raspberry Pi pages) — that list was complete until this PR, and --id is the member of it a server sees.
| # Shell commands run when a stream starts and when it stops -- an amplifier relay, a | ||
| # light. `/bin/sh -c`, with the event's facts in SENDSPIN_* environment variables: | ||
| # SENDSPIN_EVENT (start|stop) always, and SENDSPIN_SERVER_ID, SENDSPIN_SERVER_NAME, | ||
| # SENDSPIN_SERVER_URL and SENDSPIN_CLIENT_NAME where known. The hook runs without |
There was a problem hiding this comment.
Fixed — the annotated hook-env list now names SENDSPIN_CLIENT_ID. --help was missing it too, for the same reason, and now names it again.
The client id was the library's MAC-derived default with no way to choose one, and the client/hello device info was hardcoded. The id is the half that bites: it is the stable identity a server files volume, group membership and pairing under -- -n is only what it displays -- and two players on one host derive the same MAC, so each server-side setting lands on whichever connected last. The dual-mono two-daemons-one-host pattern needs a flag; the Python CLI has all three. --id sets SendspinClientConfig::client_id (config key `id`). The default stays empty on purpose: the library derives the MAC-based id only when nothing is set, and that remains the right identity for one fixed endpoint per host. The flag also feeds the stream hooks' SENDSPIN_CLIENT_ID, until now reserved but never set -- the derived id is not exposed by the library, so the flag's value is the first honest one a hook can be handed. --manufacturer and --product-name override the hello device info, for the integrator whose product embeds this player and should be listed as itself. Defaults stay sendspin-cpp-cli / sendspin-cli. All three are refused empty, warned about on a subcommand run like every other daemon-only flag, and settable from the config file through the same apply_option() door. Verified against a real aiosendspin server: the connected client reports the --id value as its client_id, and the start hook exports it as SENDSPIN_CLIENT_ID. The dual-instance guidance in --help and the README now names --state-dir beside --id and --port. state_store_path() is namespaced by neither, so two daemons on one host overwrite each other's volume, mute, delay and last server; the annotated example config and state_store.cpp already said so and these two did not. That example config's hook-env list gains SENDSPIN_CLIENT_ID, which this change is what sets. The four passages that already enumerated what a second player on one host needs -- the README's state-file section, the wiki's Configuration, Troubleshooting and Raspberry Pi pages -- name --id too. They listed --port, --state-dir and a control socket, which was the whole list until this change; --id is now the one of the four that a server sees. --help names SENDSPIN_CLIENT_ID among the hook's variables again. It was dropped because nothing set it and a flag's own help must not promise a variable that cannot arrive; this is the flag that makes it arrive, and --help was the last surface still silent about it.
49780a8 to
ee1edbe
Compare
Second gap from the daemon-parity audit: identity. The client id was the library's MAC-derived default with no way to choose one, and the
client/hellodevice info was hardcoded.Why the id matters
client_idis the stable identity a server files volume, group membership and pairing under —-nis only what it displays. Two players on one host derive the same MAC, so each server-side setting lands on whichever connected last; the dual-mono two-daemons-one-host pattern was impossible. The Python CLI has all three flags.What it adds
--id <id>(config keyid) setsSendspinClientConfig::client_id. The default stays empty on purpose: the library derives the MAC-based id only when nothing is set, and that remains the right identity for one fixed endpoint per host. The flag also feeds the stream hooks'SENDSPIN_CLIENT_ID— reserved in Run stream hooks on stream start and stop #28 but never set, because the derived id is not exposed by the library; the flag's value is the first honest one a hook can be handed.--manufacturer/--product-name(config keysmanufacturer/product-name) override the hello device info, for the integrator whose product embeds this player and should be listed as itself. Defaults staysendspin-cpp-cli/sendspin-cli.apply_option()door as every other key.Two doc corrections that came out of review
--helpand the README named--idand--portbut not--state-dir.state_store_path()is namespaced by neither, so two daemons on one host overwrite each other's volume, mute, delay and last-server state. The annotated example config andstate_store.cppalready said so; these two now agree with them.SENDSPIN_CLIENT_ID, which this change is what sets.Testing
ConfigMerge.AConfiguredControlSocketIsAbsolutizedUnderDaemonize, which asserts a socket path fits insun_pathand fails only because this checkout's directory is long enough to push the path to 107 bytes against a 103-byte limit — unrelated to this change and green on a shorter path.aiosendspinserver: the connected client reports the--idvalue as itsclient_id, and the start hook exportsSENDSPIN_CLIENT_ID=kitchen-left.Docs updated:
--help, README (flag list + dual-mono note, hooks table), wikiConfiguration.mdkey table, wikiControlling-the-Player.md, the annotated example config, anddocs/ROADMAP.md(item 23; item 22's CLIENT_ID caveat resolved).Rebased onto
mainnow that #28 has merged, so this is the identity change alone. The one hook file it still touches issrc/hooks.h, for the one-lineclient_iddoc comment that #28 left pointing at a flag that did not exist yet.Of Copilot's six review comments, three are addressed here (the two
--state-dirones and the example config's hook-env list) and two were already fixed onmainby later commits on #28. The remaining two are #28's code rather than this change's, and are filed as #33 and #34.