Skip to content

Run stream hooks one at a time, newest event winning the wait - #41

Merged
chrisuthe merged 1 commit into
mainfrom
fix/hook-serialisation
Aug 28, 2026
Merged

chrisuthe merged 1 commit into
mainfrom
fix/hook-serialisation

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

Hooks were spawned side by side and never ordered against each other, so a start hook that ran long could finish after the stop hook of its own stream and leave an amplifier on with the player idle -- the exact state the hooks exist to prevent. Nothing bounded how many children could be outstanding either: repeated stream transitions against a hanging hook accumulated processes without limit.

One hook now runs at a time. While it runs, the newest event waits in a single pending slot and a newer event replaces whatever waits there, because the hardware should end in the final state rather than replay a stale intermediate; each replacement is a debug line. That slot is also the bound: at most one child and one waiting event, however a hook misbehaves.

The shutdown path flushes the slot after the stream-end drain, spawning the pending stop hook beside a start hook that never finished -- at WARN, since it means a hook has hung -- so stopping the player still switches the amplifier off.

Fixes #33

Hooks were spawned side by side and never ordered against each other,
so a start hook that ran long could finish after the stop hook of its
own stream and leave an amplifier on with the player idle -- the exact
state the hooks exist to prevent. Nothing bounded how many children
could be outstanding either: repeated stream transitions against a
hanging hook accumulated processes without limit.

One hook now runs at a time. While it runs, the newest event waits in a
single pending slot and a newer event replaces whatever waits there,
because the hardware should end in the final state rather than replay a
stale intermediate; each replacement is a debug line. That slot is also
the bound: at most one child and one waiting event, however a hook
misbehaves.

The shutdown path flushes the slot after the stream-end drain, spawning
the pending stop hook beside a start hook that never finished -- at
WARN, since it means a hook has hung -- so stopping the player still
switches the amplifier off.

Fixes #33
@chrisuthe
chrisuthe merged commit 5433bc0 into main Aug 28, 2026
12 checks passed
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.

Stream hooks are unbounded and unordered: a slow start hook can outlive its stop hook

1 participant