Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/src-tauri/src/meet_audio/audio_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@
" state=" +
ctx.state
);
// Keepalive: a permanently-running source of zero samples connected
// to `dest`. Without this, Meet sees an audio track that is `live`
// but produces zero PCM during silence — some Meet builds drop the
// bot for "no audio activity" after a few seconds. Mirrors the
// camera-bridge 1px-bob keepalive in `meet_video/camera_bridge.js`
// (see comment "keeps the WebRTC encoder from dropping the stream
// as 'frozen'"). Brain PCM mixes in via `__openhumanFeedPcm` over
// the top — zero + real = real, so this does NOT mute the bot.
//
// NOT pushed into `activeSources`: barge-in (`__openhumanFlushAudio`)
// must not stop the keepalive.
try {
var silenceSamples = Math.max(1, Math.floor(ctx.sampleRate / 10)); // 100 ms
var silenceBuffer = ctx.createBuffer(1, silenceSamples, ctx.sampleRate);
// createBuffer initializes to zeros — no explicit fill needed.
var silenceSource = ctx.createBufferSource();
silenceSource.buffer = silenceBuffer;
silenceSource.loop = true;
silenceSource.connect(dest);
silenceSource.start(0);
console.log(
"[openhuman-audio-bridge] keepalive silence source started buffer_samples=" +
silenceSamples
);
} catch (e) {
// Keepalive failure is non-fatal — the bridge still functions for
// active speech. Log so support can spot it in user reports.
console.warn(
"[openhuman-audio-bridge] keepalive setup failed err=" + e
);
}
return ctx;
}

Expand Down
29 changes: 29 additions & 0 deletions app/src-tauri/src/meet_audio/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,32 @@ pub async fn flush_audio_bridge(cdp: &mut CdpConn, session: &str) -> Result<i64,
.unwrap_or(0);
Ok(stopped)
}

#[cfg(test)]
mod tests {
use super::AUDIO_BRIDGE_JS;

/// The page-side audio bridge must contain a permanent zero-PCM
/// keepalive source connected to the WebRTC destination. Without
/// it, Meet drops the bot for "no audio activity" during silence
/// (see `docs/superpowers/specs/2026-06-04-meet-audio-keepalive-design.md`).
///
/// This is a presence test — it does not exercise the WebAudio
/// runtime, only asserts the keepalive code shipped intact in the
/// included JS. If a future refactor moves the keepalive to a
/// different file or reshapes the log line, update the assertions
/// here together with the change.
#[test]
fn audio_bridge_contains_keepalive_block() {
assert!(
AUDIO_BRIDGE_JS.contains("keepalive silence source started"),
"audio_bridge.js is missing the keepalive console.log marker; \
the silence source may have been removed (see #2945)"
);
assert!(
AUDIO_BRIDGE_JS.contains("silenceSource.start(0)"),
"audio_bridge.js is missing `silenceSource.start(0)`; \
the keepalive setup may have been removed (see #2945)"
);
}
}
Loading
Loading