zebra-spaces: telemetry on listener audio path

Server log was silent on what the phone was doing after my last
change. Adding logLine() in three places so the next attempt is
diagnoseable from CLIENT_LOG without asking fox to relay phone
screen content:

 - autoEnableDjModeForListener: how many members it saw, how many
   pubHexes it actually added to streamMode.
 - applyAudioMute: how many <audio> elements got their muted state
   touched, per-element play() rejections.
 - btn-mute click as listener: current listenerOutputMuted +
   sizes of remoteAudio / streamAudio / audioPath maps so we know
   if the click is firing and what state it sees.
This commit is contained in:
Russell Ballestrini 2026-06-03 21:04:22 -04:00
parent d9be0e4cda
commit f196714410
No known key found for this signature in database

View file

@ -4085,20 +4085,32 @@ const audioPath = new Map(); // uuid -> 'dj' | 'rtc'
let listenerOutputMuted = true;
function applyAudioMute(){
const silenced = (myRole === 'listener' && listenerOutputMuted);
let touched = 0, played = 0, failed = 0;
for (const [uuid, a] of remoteAudio){
const wantRtc = !silenced && audioPath.get(uuid) !== 'dj';
try {
a.muted = !wantRtc;
if (wantRtc) { const p = a.play(); if (p && p.catch) p.catch(()=>{}); }
} catch(_){}
touched++;
if (wantRtc) {
const p = a.play();
if (p && p.then) p.then(()=>played++).catch(e=>{ failed++; logLine('err','rtc play '+uuid+': '+e.message); });
else played++;
}
} catch(e){ failed++; logLine('err','rtc set mute '+uuid+': '+e.message); }
}
for (const [uuid, a] of streamAudio){
const wantDj = !silenced && audioPath.get(uuid) === 'dj';
try {
a.muted = !wantDj;
if (wantDj) { const p = a.play(); if (p && p.catch) p.catch(()=>{}); }
} catch(_){}
touched++;
if (wantDj) {
const p = a.play();
if (p && p.then) p.then(()=>played++).catch(e=>{ failed++; logLine('err','dj play '+uuid+': '+e.message); });
else played++;
}
} catch(e){ failed++; logLine('err','dj set mute '+uuid+': '+e.message); }
}
logLine('', 'applyAudioMute silenced='+silenced+' touched='+touched+' streamMode='+streamMode.size);
}
function streamUrlFor(pubHex){
return SFU_BASE + '/stream?room=' + encodeURIComponent(roomID) + '&pub=' + pubHex;
@ -4189,9 +4201,11 @@ function toggleStreamFor(uuid, pubHex){
* - role-change (another peer became a speaker; or we got demoted
* to listener). */
function autoEnableDjModeForListener(){
if (myRole !== 'listener') return;
if (myRole !== 'listener') { logLine('', 'autoDJ skip: role='+myRole); return; }
let added = 0, seen = 0;
for (const [uuid, mm] of members){
if (uuid === myUUID) continue;
seen++;
if (!canSpeak(mm.role)) continue;
if (!mm.pubkey) continue;
let pubHex;
@ -4199,7 +4213,9 @@ function autoEnableDjModeForListener(){
if (streamMode.has(pubHex)) continue;
streamMode.add(pubHex);
startStream(uuid, pubHex);
added++;
}
logLine('', 'autoDJ pass: members='+seen+' added='+added+' streamMode='+streamMode.size);
}
/* Periodic retry — covers the timing race where the host's mic publish
* hasn't been registered at the SFU yet when the listener first
@ -4646,6 +4662,10 @@ $('btn-mute').addEventListener('click', () => {
* waiting. */
if (myRole === 'listener'){
listenerOutputMuted = !listenerOutputMuted;
logLine('', 'play-button: listenerOutputMuted=' + listenerOutputMuted +
' remoteAudio=' + remoteAudio.size +
' streamAudio=' + streamAudio.size +
' audioPath=' + audioPath.size);
applyAudioMute();
const btn = $('btn-mute');
btn.textContent = listenerOutputMuted ? 'play' : 'mute';
@ -4887,8 +4907,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');
<footer style="margin:2.2rem auto 0;font-size:0.65rem;color:#999;line-height:1.7;word-break:break-all;font-family:monospace">
<span id="pi-seal" style="color:#777;cursor:default;user-select:none" title="">page integrity</span> &nbsp;·&nbsp; built <span class="stamp-date">2026-06-04</span><br>
md5 <span class="stamp-md5">63bf820f7f0bc11d4726b3f1550380f6</span><br>
sha256 <span class="stamp-sha">6a259843e45682d391e7485fd11b670eea32b8622846529b3a319f2a375420a8</span><br>
md5 <span class="stamp-md5">62e317cdbfd3e536107c394d0380e36c</span><br>
sha256 <span class="stamp-sha">4e3cee1e45894ed48628267704c5658fca14da3ca169de4366f69e4c3e48fc0c</span><br>
<span style="color:#bbb">hashes are of this page with these two fields zeroed — to verify, blank them and re-hash</span><br>
<span style="color:#bbb">one self-contained file — <strong>save a copy</strong> and verify against these hashes; point at your own servers with ?signal= and ?turncred=, or <a href="host-your-own.html" style="color:#999">host your own community</a></span>
</footer>