Pause playback while transmitting and declare microphone use.

macOS refuses capture without a usage string, and queued remote audio was still handed to the speaker after push-to-talk began.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Konrad Neitzel
2026-10-03 16:32:01 +02:00
co-authored by Cursor
parent 9c4f6621fc
commit 6233292931
9 changed files with 44 additions and 15 deletions
+26
View File
@@ -360,6 +360,32 @@ func TestRemoteAudioAndTalker(t *testing.T) {
}
}
func TestPlaybackPausesWhenTransmitting(t *testing.T) {
in := login(t, "DL1ABC", "key", 20, 7, []string{"OPUS"})
enc, err := opus.NewEncoder()
if err != nil {
t.Fatal(err)
}
defer enc.Close()
pkt, err := enc.Encode(make([]int16, opus.FrameSamples))
if err != nil {
t.Fatal(err)
}
in.refl.writeUDP(t, 101, 7, 1, appendBytes(nil, pkt))
in.refl.writeUDP(t, 101, 7, 2, appendBytes(nil, pkt))
if _, err := in.st.WaitPlayback(t.Context(), 2*opus.FrameSamples-1); err != nil {
t.Fatal(err)
}
in.st.HoldButton()
in.refl.writeFrame(t, 105, appendStr(appendU32(nil, 20), "DB0XYZ"))
if _, err := in.st.Wait(t.Context(), func(s station.State) bool { return s.Transmitting }); err != nil {
t.Fatal(err)
}
if pcm := in.st.TakePlayback(); len(pcm) != 0 {
t.Fatalf("playback %d samples, want none while transmitting", len(pcm))
}
}
func TestMicrophoneIsNotPlayed(t *testing.T) {
in := login(t, "DL1ABC", "key", 20, 7, []string{"OPUS"})
in.st.HoldButton()