Commits
2026-08-13
🔀 merge: main's live underrun query beside the lane's ownAhmet Kaan Gümüş · 64a9817
🔀 merge: main's live underrun query beside the lane's own Their `ao_underruns(session, last_at)` is the richer of the two -- it says where the last starved callback was, not only how many there have been -- so it is the one that stays, required symbol and all. What this lane keeps is the *meaning* of the number it reports: the `primed` gate in the RT callback, so the head of a restart and the tail of a played-out stream are not counted, and `ao_stream_ended` beside it.
🐛 fix(audio): a stream that has ended is not a decoder that fell behindAhmet Kaan Gümüş · c179364
🐛 fix(audio): a stream that has ended is not a decoder that fell behind The last unattributed underruns were the *tail* of a stream: once the decoder is done, the ring drains and every quantum after it was counted as lateness, though there was nothing left to be late with. Ten to sixteen per session on a file played to its end, four hundred on a cold scrub. `ao_stream_ended` (optional symbol, like the counter) unprimes the flag when the feeder's decode channel closes -- under the device lock and past the epoch check, so a superseded feeder cannot say it about the stream that replaced it. What is already queued still plays out untouched: this is not a flush and not a pause. The device is also stopped where the audio really is over (`tick`'s played-out branch), since nothing will ever be queued for that stream again, and the stamp goes with it so a later play defers to the first sample of whatever comes next. Whole `--include-ignored` playback suite, 31 sessions: not one `engine_audio: N underruns` line left, where the same run printed 9-16 for `seek_past_the_end_clamps` and ~400 for a 200-step cold scrub before.
🐛 fix(audio): the device waits for a sample instead of playing its own silenceAhmet Kaan Gümüş · 290699e
🐛 fix(audio): the device waits for a sample instead of playing its own silence A seek made the output active before its stream existed: the open runs on the feeder now, so a cold one left the device playing an empty ring and counting a starved quantum for every millisecond of it -- 1721 of them over a scripted cold play-seek-scrub, against 5 warm. The count stopped meaning "the decoder was late" and started meaning "a seek happened". The intent to play is now a flag (`Audio::wants_active`) written under the device lock beside the `content_at` stamp the feeder writes there, so whichever side takes the lock first the other sees its half: the device is started by the first real sample, and a pause landing during an open can never be overtaken by a late activation. Two halves it needed on the way: - the ring refuses a write while a flush is pending and only a *running* device's callback clears the flag, so a device that waits for the write and a write that waits for the device park on each other -- the feeder therefore starts the device on that refusal too, with the sample already in hand. - the restart's own head is no longer counted at all: `Shared::primed` is false from the open and from every flush until something is queued, and a callback that finds nothing while it is false is a stream that has not started rather than a decoder that fell behind. That also takes the callbacks between the connect and the first write out of the count. `ao_underruns` exposes the counter live (optional symbol: a plugin without it plays, it just cannot say), so a storm can attribute starvation to the seek that caused it instead of reading one number at exit. Guard: 50 random seeks into the 2h film off a cold cache, every one of them required to resume -- 0 underruns, where the same storm counted one per seek before.
✨ feat(bench): a seek storm and a play loop, and the underruns they costAhmet Kaan Gümüş · 8271b5d
✨ feat(bench): a seek storm and a play loop, and the underruns they cost The complaint is a long film jumped around in: the sound runs dry and the picture jumps. Neither was measurable. The audio plugin counted its starved callbacks and only whispered them on the way out, so a session could be asked nothing while it ran; `ao_underruns` reads the same counter -- two relaxed atomic loads, nothing added to the RT path but one store on the starved branch -- and `PlaybackSession::audio_underruns` hands it over in device seconds. The picture's half is `restarts`, counted where a worker is replaced, so a seek, a clip boundary and a late-picture resync all land in one number. Two metrics use them. `seekstorm` plays the file and seeks fifty seeded random places, cold then warm, and reports first-frame p50/p95/max beside the underruns each pass cost -- playing, because a paused device runs no callbacks and can never starve. `playloop` runs the app's own pump for N seconds with a jump every five, and reports the gap between frames (p50/p99), the underruns and the restarts, with its own count of late-picture resyncs beside them. Both name the decode backend in the note, as seek and scrub already do: a row that does not say `backend HW` was measured in software. And it would have been. `cargo build -p engine-hw --example bench` selects example targets in every package it is given, and a cdylib is not one, so the line that exists to build the plugin built nothing and the LD_LIBRARY_PATH below it pointed at an empty directory. The plugins are their own build now.
2026-08-10
🔊 feat(audio): volume and mute for the monitoring outputAhmet Kaan Gümüş · bb07bdc
🔊 feat(audio): volume and mute for the monitoring output One knob down the stack: `ao_set_volume(handle, gain)` scales the samples in the RT callback, and mute is a gain of 0.0. Not the stream's PipeWire volume control -- WirePlumber persists every Props change into its restore state (measured on this box: the bucket gains `mute:true` ~2 s later), so a mute keypress would have become "edith has no sound" in tomorrow's system mixer, which is the bug 9ab4ebd just finished removing. Volume and mute stay independent: turning the level down while muted must not be what makes sound come out. The button says both at once. Mute is not pause -- the frames are still consumed, so the device clock, and with it the picture, runs straight through. The keybindings card's row list now scrolls inside a cap, which is the upgrade path its own ponytail named: three more actions no longer fit a 360 px window, and now no number of them can stop fitting.
2026-08-09
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_atAhmet Kaan Gümüş · 96ae365
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_at Lane 1 of the seek slice; PlaybackSession orchestration comes next. - demux/decode: stss sync lookup, DecodeSession::open_at decodes from the keyframe and discards to the target; Frame.index stays absolute. HW plugin ABI: vh_open renamed vh_open_at(path, target) — discards skip the vaGetImage readback; measured seek cost 65ms HW / 222ms SW - engine-audio: ao_flush drains the ring consumer-side in the RT callback (one-shot atomic), stale PCM unplayable even when paused; played-position atomics untouched so clock math survives - audio: open_at walks stts, 2-packet AAC pre-roll (MDCT overlap reconstructed exactly — verified 0-diff before the first PNS band), sample-exact trim; priming skip and seek discard unified. AAC seek is deliberately not bit-exact: symphonia's PNS noise LCG state depends on packet history; bounded <1e-3 by test instead
✨ feat(engine): audio decode, PipeWire output plugin, playback clockAhmet Kaan Gümüş · 229a569
✨ feat(engine): audio decode, PipeWire output plugin, playback clock Wave 1 of the audio slice — three independent modules, app wiring comes next: - audio.rs: AAC-LC via standalone symphonia AacDecoder over the existing mp4 demuxer; priming trim read from the container elst (verified against ffprobe); channel identity pinned by zero-crossing tests on the 440/880 Hz fixture - engine-audio: dlopen'd PipeWire cdylib (ao_* C ABI). App binary keeps zero libpipewire linkage; daemon absent fails open() in ~1ms. Fill capped at 1024 frames/callback: uncapped, PipeWire hands the sink-sized buffer and the position clock steps 256ms at a time. Stream time rate is 1/48000 regardless of stream rate — position is rescaled or the clock runs 8.8% fast on 44.1k content - clock.rs: PlaybackClock, audio-driven with wall fallback; audio positions relative to last re-anchor so restarted streams re-sync; paused == frozen exactly, all re-anchoring through one path