Skip to content

Commit 9fa0d32

Browse files
mkschulzeclaude
andcommitted
fix(14.2): add 30s probe timeout to prevent indefinite silence encoding
The probe phase broadcast indefinitely when measurement never completed (e.g., solo or peer on older build without instamode fix). After 30s the Instatalk switches to PTT-driven mode regardless, eliminating CPU spikes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e9fc2a1 commit 9fa0d32

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

juce/NinjamRunThread.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ void NinjamRunThread::handleStatusChange(NJClient* client, int currentStatus)
380380
},
381381
&processor);
382382
lastInstatalkPtt_ = true; // matches initial broadcasting=true (probe phase)
383+
probeDeadlineMs_ = juce::Time::currentTimeMillis() + 30000; // 30s probe window
383384

384385
// Reset measurement state for new session (allows re-measurement per review concern #5).
385386
client->resetInstaMeasurement();
@@ -528,7 +529,9 @@ void NinjamRunThread::syncInstatalkBroadcast(NJClient* client)
528529
// This avoids continuous Vorbis encoding of silence (which caused CPU spikes
529530
// at every interval boundary) while still allowing automatic probe measurement.
530531
bool measured = processor.instaMeasurementBroadcast.load(std::memory_order_relaxed);
531-
bool want = measured
532+
bool probeExpired = probeDeadlineMs_ > 0
533+
&& juce::Time::currentTimeMillis() > probeDeadlineMs_;
534+
bool want = (measured || probeExpired)
532535
? processor.pttActive.load(std::memory_order_relaxed) // PTT-driven
533536
: true; // probe: always on
534537

juce/NinjamRunThread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class NinjamRunThread : public juce::Thread
5353

5454
// Phase 14.2: track PTT state to toggle Instatalk broadcasting
5555
bool lastInstatalkPtt_ = false;
56+
juce::int64 probeDeadlineMs_ = 0; // probe phase timeout (0 = not set)
5657

5758
// Prelisten connection metadata (stored from PrelistenCommand for event emission)
5859
std::string prelistenHost_;

0 commit comments

Comments
 (0)