Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix: after a meeting on headphones, the next meeting on speakers no longer lets the first online sentence into the room's lines

wquguru4f72d4b2ab29
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swift
index 20f8bf1..181b20b 100644
--- a/Sources/Cicada/AppModel.swift
+++ b/Sources/Cicada/AppModel.swift
@@ -1314,6 +1314,8 @@ final class AppModel: ObservableObject {
// macOS 14/15: two live recognizers interrupt each other (docs/macos-legacy-plan.md 2, 10).
guard !roomListen.isRunning, !Recognition.legacy else { return }
roomListen.echoCancelled = roomEchoCancel
+ // Last meeting's measurement may be another room or another output: assume echo until measured.
+ roomListen.echoGate.reset()
// A, the gate: only the plain room mic heeds it (echo cancellation keeps talk over a remote speaker).
listen.router.setOnLoud(roomEchoGate ? { [gate = roomListen.echoGate] in gate.hold() } : nil)
roomListen.start()
@@ -2308,6 +2310,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, UNUs
MainActor.assumeIsolated {
debugLog("default output device changed → reconnecting tap")
self?.model.listen.reconnectAudio()
+ // Headphones in or out: whether the speakers reach the room mic is measured again.
+ self?.model.roomListen.echoGate.reset()
self?.model.refreshOutputs()
}
}
diff --git a/Sources/Cicada/RoomMic.swift b/Sources/Cicada/RoomMic.swift
index f249183..85c61b7 100644
--- a/Sources/Cicada/RoomMic.swift
+++ b/Sources/Cicada/RoomMic.swift
@@ -154,6 +154,17 @@ final class EchoGate: @unchecked Sendable {
/// Debug (`roomEchoSim:<on|off>`): pretend the measurement says this.
var forced: Bool?
+ /// Forget what was measured: the speakers are taken to echo until measured again (a new
+ /// meeting, or the output moved between speakers and headphones).
+ func reset() {
+ lock.withLock {
+ during = []
+ quiet = []
+ _echo = true
+ }
+ debugLog("room echo: measuring again")
+ }
+
/// A loud block of the Mac's audio, on the main engine's audio queue.
func hold(now: Double = CFAbsoluteTimeGetCurrent()) {
lock.withLock {
diff --git a/Tests/CicadaTests/HybridTests.swift b/Tests/CicadaTests/HybridTests.swift
index 234fcb7..765c4ac 100644
--- a/Tests/CicadaTests/HybridTests.swift
+++ b/Tests/CicadaTests/HybridTests.swift
@@ -110,6 +110,16 @@ import Testing
#expect(g.echo)
}
+ @Test func aResetAssumesEchoAgain() {
+ let g = EchoGate()
+ play(g, from: 0, to: 6, words: true, during: 0.001, quiet: 0.001)
+ #expect(!g.echo)
+ g.reset()
+ #expect(g.echo)
+ g.hold(now: 50)
+ #expect(g.closed(now: 50.1))
+ }
+
@Test func notEnoughToTellKeepsTheEcho() {
#expect(EchoGate.ratio(during: [(0.001, 1)], quiet: [(0.001, 10)]) == nil)
#expect(EchoGate.ratio(during: [(0.001, 5)], quiet: [(0.001, 1)]) == nil)