From a27ea202a735d5aac418938b109b433871c68d2e Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Sun, 16 Aug 2026 12:39:38 -0400 Subject: [PATCH] =?UTF-8?q?Room=20audio=20grows=20ears=20for=20its=20own?= =?UTF-8?q?=20health:=20the=20sender=20meters=20the=20tapped=20stream=20ev?= =?UTF-8?q?ery=205=20s=20(peak=20+=20client=20count)=20and=20the=20receive?= =?UTF-8?q?r=20logs=20once=20when=20genuinely=20non-silent=20audio=20arriv?= =?UTF-8?q?es=20=E2=80=94=20because=20a=20room=20whose=20every=20leg=20rep?= =?UTF-8?q?orts=20locked=20can=20still=20be=20carrying=20pure=20silence,?= =?UTF-8?q?=20and=20that=20failure=20was=20indistinguishable=20from=20succ?= =?UTF-8?q?ess=20in=20the=20logs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ACMacAudio/RoomReceiver.swift | 5 +++++ .../Sources/ACMacAudio/RoomSender.swift | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/slab/macos-audio/Sources/ACMacAudio/RoomReceiver.swift b/slab/macos-audio/Sources/ACMacAudio/RoomReceiver.swift index b0295056c..8b41f4df1 100644 --- a/slab/macos-audio/Sources/ACMacAudio/RoomReceiver.swift +++ b/slab/macos-audio/Sources/ACMacAudio/RoomReceiver.swift @@ -128,6 +128,7 @@ public final class ACAudioRoomReceiver: @unchecked Sendable { private let store = ACAudioPacketStore() private var nonce: UInt32 = 0 private var didLogAudio = false + private var didLogSignal = false private var lastTrafficNanos: UInt64 = 0 public init(configuration: Configuration) { self.configuration = configuration } @@ -232,6 +233,10 @@ public final class ACAudioRoomReceiver: @unchecked Sendable { self.didLogAudio = true self.log("audio locked at \(packet.sampleRate) Hz, \(self.configuration.channel.name), gain \(self.configuration.gain)") } + if !self.didLogSignal, packet.pcm16.contains(where: { $0 > 2 && $0 < 254 }) { + self.didLogSignal = true + self.log("signal present (non-silent audio arriving)") + } default: break } } diff --git a/slab/macos-audio/Sources/ACMacAudio/RoomSender.swift b/slab/macos-audio/Sources/ACMacAudio/RoomSender.swift index 524fa4198..bfd15bdf1 100644 --- a/slab/macos-audio/Sources/ACMacAudio/RoomSender.swift +++ b/slab/macos-audio/Sources/ACMacAudio/RoomSender.swift @@ -30,6 +30,7 @@ public final class ACAudioRoomSender: @unchecked Sendable { private var sequence: UInt32 = 0 private var nextPresentationNanos: UInt64 = 0 private var lastAudioNanos: UInt64 = 0 + private var lastMeterNanos: UInt64 = 0 public init(configuration: Configuration = .init()) { self.configuration = configuration @@ -147,6 +148,23 @@ public final class ACAudioRoomSender: @unchecked Sendable { return } + // Level meter every ~5 s: "locked but silent" downstream is + // indistinguishable from success without knowing what the tap + // actually carries. + let meterNow = ACHostClock.nowNanos() + if meterNow &- lastMeterNanos > 5_000_000_000 { + lastMeterNanos = meterNow + var peak: Float = 0 + for channel in 0..<2 { + for frame in 0.. peak { peak = v } + } + } + log(String(format: "tap level peak %.4f (%u frames, %d clients)", + peak, output.frameLength, connectedClients.count)) + } + let now = ACHostClock.nowNanos() if nextPresentationNanos == 0 || now > lastAudioNanos + 250_000_000 { session = UInt32.random(in: 1...UInt32.max) -- 2.51.2