feat(ptt,audio): wire PTT key edges through ReleaseTailTimer (SDD-096)
Previously the PttController handed its real AudioTransmitGate to the platform backend and the backend wrote transmit_active directly on every key edge — bypassing the 200 ms release tail and the TransmitMode selector entirely. The tail timer was constructed and exposed on ChanoraSession but never received any input, so SDD-096 and SRS-206 were spec-only. Wire it: PttController now owns a synthetic 'press-edge gate' which it hands to the backend in place of the real one. An internal edge-watcher task subscribes to that press-gate, translating true/false transitions into ReleaseTailTimer.key_down/key_up calls. The release-tail timer feeds the selector's ptt_held input; the selector recomputes transmit_active honouring mode, in_channel, and hard_mute, and writes the real gate. Single owner of transmit_active is preserved (SAD-083 invariant). PttController::new now takes Arc<ReleaseTailTimer> instead of AudioTransmitGate; ChanoraSession threads its session-scoped timer through both the start_audio path and the supervisor reconnect path. The legacy bridge set_ptt call (still used by the in-focus Listener fallback and the e2e test) is rerouted through the timer so the same tail and mute semantics apply uniformly. ReleaseTailTimer gains force_release() — cancels any pending task AND clears the selector's ptt_held. PttController::stop uses it so shutdown can't leave transmit_active stuck at true. Tests - press_edge_drives_selector_through_release_tail: backend press edge → real gate follows, key_up → tail keeps gate true for tail window then clears. - stop_clears_press_and_cancels_tail: stop() drops transmit even with a tail in flight. - e2e test now sets release_tail_ms=0 + waits one tick so the pttActive=false assertion isn't racing the default 200 ms tail. cargo test --workspace --lib: 74 passed / 0 failed / 1 ignored (+2 new tests vs. the previous 72). flutter analyze: clean (6 pre-existing Radio.groupValue infos).
This commit is contained in:
@@ -100,6 +100,16 @@ impl ReleaseTailTimer {
|
||||
self.cancel_pending();
|
||||
}
|
||||
|
||||
/// Cancel any pending release task and immediately clear the
|
||||
/// selector's `ptt_held` input. Used on PTT controller
|
||||
/// shutdown to guarantee `transmit_active` does not get stuck
|
||||
/// at `true` if the user's last action was a key-down with
|
||||
/// no matching key-up reaching us before the shutdown.
|
||||
pub fn force_release(&self) {
|
||||
self.cancel_pending();
|
||||
self.selector.set_ptt_held(false);
|
||||
}
|
||||
|
||||
fn cancel_pending(&self) {
|
||||
if let Ok(mut g) = self.pending.lock() {
|
||||
if let Some(h) = g.take() {
|
||||
|
||||
Reference in New Issue
Block a user