Skip to content

sip: a retrieve right after the parker's BYE keeps its audio and gets no hold music - #403

Merged
piwi3910 merged 2 commits into
mainfrom
fix/park-retrieve-audio
Nov 17, 2026
Merged

piwi3910 merged 2 commits into
mainfrom
fix/park-retrieve-audio

Conversation

@piwi3910

Copy link
Copy Markdown
Contributor

Root cause

The parker's phone gets its BYE before parkRun's byeA (or w.bye) returns, and a retrieve can land in that window. parkRetrieved attaches the retriever to the parker's relay leg (attachParty -> handOverLeg, park.go:528-531). Then parkRun carried on unconditionally (park.go:395-402 before this change):

  • relay.SetTarget(parkerLeg, nil) cleared the leg the retriever had just been attached to. The parked party's audio was dropped until the retriever's own RTP latched the leg again, so the call could stay one-way.
  • parkHold started the music on hold on the parked party's leg. parkRetrieved had already called stopParkMusic, so the music played over the retrieved call until parkHold saw the halt.

Fix

  • parkRun releases the parker's leg only while the call is still parked. It checks c.park == pk && pk.phase == phaseParked under c.mu, the same lock parkRetrieved takes to leave that phase. If a retrieve has already won, parkRun returns without entering parkHold.
  • parkHold starts the music under the same lock, and only for a call that is still parked and not ended.

A retrieve now either comes after the clear and attaches over it, or comes first and finds the leg and the party untouched.

Test

TestCallParkRetrieveAsParkerLeaves holds the park goroutine right after the parker's BYE. It uses parkerGoneHook, a new test-only hook in the style of callerByeHook. The test retrieves in that window and then checks two things:

  1. The parked party gets no RTP while nobody talks, so no music on hold.
  2. The parked party's first packet reaches the retriever's SDP address before the retriever has sent anything.

Verification

  • On the old code both checks fail: received 1 RTP packets ... (music on hold) and the retriever's SDP address did not get the parked party's audio.
  • With the fix:
    • go test -race -count=50 -run TestCallParkRetrieveAsParkerLeaves ./internal/sip/ passes 50/50.
    • -race -count=3 over the park, pickup and session-timer-after-park tests passes.
    • go test ./internal/sip/ passes.

… no hold music

The parker's phone gets its BYE before parkRun's byeA (or w.bye) returns,
and a retrieve can land in that window. parkRetrieved attaches the
retriever to the parker's relay leg (attachParty -> handOverLeg). Then
parkRun went on as if nothing had happened:

- relay.SetTarget(parkerLeg, nil) cleared the leg the retriever had just
  been attached to. The parked party's audio was dropped until the
  retriever's own RTP latched the leg again. A phone that sends nothing
  first, or sends from its SDP address only after hearing something,
  stayed one-way.
- parkHold started the music on hold on the parked party's leg and
  stored it in pk.music. parkRetrieved had already passed its
  stopParkMusic, so the music played over the retrieved call until
  parkHold's loop saw the halt.

parkRun now releases the parker's leg only while the call is still
parked. It checks c.park and pk.phase under c.mu, which is the lock
parkRetrieved takes to leave the parked phase, and returns without
entering parkHold once a retrieve has won. parkHold starts the music
under the same lock, and only for a call that is still parked and not
ended. So a retrieve either comes after the clear and attaches over it,
or comes before and the leg and the party are left alone. A retrieve
that comes after the music started stops it, as before.

TestCallParkRetrieveAsParkerLeaves holds the park goroutine right after
the parker's BYE (parkerGoneHook, tests only) and retrieves in that
window. It then checks two things: the parked party gets no RTP while
nobody talks, and the parked party's first packet reaches the
retriever's SDP address before the retriever has sent anything. Before
the fix both checks fail ("received 1 RTP packets ... (music on hold)",
"the retriever's SDP address did not get the parked party's audio"). After
the fix, -race -count=50 passes 50/50. The park, pickup and session-timer
tests pass with -race -count=3, and the internal/sip package passes.
@piwi3910
piwi3910 merged commit 342b41c into main Nov 17, 2026
29 checks passed
@piwi3910
piwi3910 deleted the fix/park-retrieve-audio branch November 17, 2026 09:48
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.

1 participant