Commit 55b7cc2
committed
mirror: never write the receiver's volume when audio is disabled
`volume: 0.000000` is 0 dB, which in AirPlay is full scale -- maximum, not
silence. Two paths sent it for sessions that carry no audio, so `-no-audio`
discarded whatever volume the user had set on the receiver.
setupMirrorSession sent it unconditionally (twice) during setup, so every
connect reset the receiver to maximum. On a TV, reconnecting a dashboard or a
mirrored window slammed the set to full volume each time.
SetAudioMuted had the same effect one click away. The daemon deliberately
routes mute/unmute to the receiver when audio is disabled (daemon.go's
`d.cfg.NoAudio || t.session.HasAudio()`), and unmuting sends audioVolumeBody
(false) -- the identical full-scale value. A no-audio session still negotiates
an audio stream, so HasAudio() reports true and the plasmoid offers a mute
toggle for a video-only session; the first press silenced the receiver and the
next set it to maximum.
Guard both. A session that transmits no audio has no use for the receiver's
audio state and should leave its volume exactly as it found it. Skipping is
preferable to sending the muted value, since -144 dB would be equally
destructive of the user's setting, just in the other direction.
The SetAudioMuted guard reads MirrorSession.noAudio, which until now was
assigned and never read. HasAudio() cannot substitute for it: it is true in
both modes, which is what made this reachable.
Echoing the receiver's own reported volume back instead was considered and
rejected. On the Roku Streambar Pro tested here, `initialVolume` from /info
stayed 0.0 across ten VolumeDown and six VolumeUp presses, so it does not
track that receiver's current volume and sending it back would still command
full scale. Other receivers may report it faithfully; this was not verified
beyond the one device.
TESTS
TestSetupMirrorNoAudioStillNegotiatesAudioSession asserted the two volume
SET_PARAMETERs as part of the expected RTSP sequence for a no-audio session,
and was the only test covering that sequence -- so updating it alone would
have left no coverage that audio sessions still set the volume. The shared
helper is parameterized over noAudio and there are now two named tests, one
per direction, plus TestSetAudioMutedRefusesWhenSessionHasNoAudio.
Each test was checked against a mutation rather than merely observed green:
reverting the setup fix fails the no-audio test, making the skip unconditional
fails the with-audio test, inverting the condition fails both, and removing
the SetAudioMuted guard fails the mute test.
Verified on a Roku Streambar Pro (model 9101R2):
-no-audio -> "[SETUP] no-audio session: skipping SET_PARAMETER volume"
(sent=0, skipped=1)
with audio -> "[SETUP] SET_PARAMETER volume=0 sent" (sent=1, skipped=0)
gofmt clean, go vet clean, go test ./... passing.1 parent b95fdec commit 55b7cc2
2 files changed
Lines changed: 79 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
651 | 653 | | |
652 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
653 | 665 | | |
654 | | - | |
655 | | - | |
656 | 666 | | |
657 | 667 | | |
658 | 668 | | |
| |||
1741 | 1751 | | |
1742 | 1752 | | |
1743 | 1753 | | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1744 | 1762 | | |
1745 | 1763 | | |
1746 | 1764 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
210 | 250 | | |
211 | 251 | | |
212 | 252 | | |
| |||
448 | 488 | | |
449 | 489 | | |
450 | 490 | | |
451 | | - | |
| 491 | + | |
452 | 492 | | |
453 | | - | |
| 493 | + | |
454 | 494 | | |
455 | 495 | | |
456 | | - | |
| 496 | + | |
457 | 497 | | |
458 | 498 | | |
459 | 499 | | |
| |||
488 | 528 | | |
489 | 529 | | |
490 | 530 | | |
491 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
492 | 538 | | |
493 | 539 | | |
494 | 540 | | |
| |||
0 commit comments