jenkins 64d0eb42f6 bstein: publish microphone watch and selected output test
Vendor tested Lesavka observer source a1ac564e. Reuse numeric-only receipts; no backend, routing or installed relay changes. Validated Kustomize, client dry-run, 70 Node tests plus recent-level test, and isolated fake-device Chromium capture/output/cleanup.
2026-12-03 11:20:27 -06:00

33 lines
1.6 KiB
JavaScript

// Existing numeric-only receipt contract; no new backend or media upload.
import {RunReporter} from './reporting.js';
/** Rotate bounded receipt windows without reopening the selected audio device. */
export class AudioReports {
constructor(status,Reporter=RunReporter) {
this.status=status;this.Reporter=Reporter;this.reporter=null;this.start=0;
this.baseline=null;this.ids=[];this.last=null;
}
snapshot(now,audio,settings,reason) {
const b=this.baseline??{};
const delta=k=>typeof audio?.[k]==='number'?Math.max(0,audio[k]-(b[k]??0)):null;
return {elapsedMs:Math.max(0,now-this.start),reason,settings:{audio:settings},video:null,
audio:audio?{...audio,inputFrames:delta('inputFrames'),processedFrames:delta('processedFrames'),
exactZeroFrames:delta('exactZeroFrames')}:null};
}
observe(now,audio,settings) {
if(this.reporter&&now-this.start>=120000) {
this.reporter.finish(this.snapshot(now,audio,settings,'120 seconds complete'));
this.remember();this.reporter=null;this.baseline=audio?{...audio}:null;
}
if(!this.reporter){this.start=now;this.reporter=new this.Reporter(this.status);}
this.last=this.snapshot(now,audio,settings,'observing');this.reporter.observe(this.last);
}
remember() {
if(this.reporter?.runId&&this.ids.length<16&&!this.ids.includes(this.reporter.runId))this.ids.push(this.reporter.runId);
}
finish(now,audio,settings,reason) {
if(!this.reporter)return;
this.reporter.finish(this.snapshot(now,audio,settings,reason));this.remember();
}
}