Creator: 'when I attempt to refresh my YPP page, I get an error about not being able to reach YouTube. Seriously?' Real log: channels.list failed (403) x3. Root cause #1 (the 403): channels.list?mine=true&part=statistics,auditDetails, contentDetails returns 403 insufficientPermissions when the token lacks the youtubepartner-channel-audit scope — which the auditDetails part ALONE requires, per the docs ('A request that retrieves the auditDetails part ... must provide an authorization token that contains the youtubepartner-channel-audit scope'). That scope is MCN partner tooling with a 2-week token-revocation rule; the app must not hold it. TASK-39's 'current scopes suffice, no re-consent' slice-1 claim was wrong for this part; mock-fake tests never touched the real API, so it shipped green and 403'd every refresh since 2026-09-22. https://developers.google.com/youtube/v3/docs/channels/list Fix: part=statistics,contentDetails only; standing flags removed from ChannelStatsService -> YppStatSnapshot surface -> YppTrackerViewModel -> drawer, replaced by an honest deep-link row ('Channel standing isn't exposed to YouTube apps — check the Earn page'). YppSnapshot standing columns stay (schema-stable, always false). channels.list failures now log the response BODY — the bare code could not name insufficientPermissions, which is what made this undiagnosable. Root cause #2 (found by the new Good Dog, masked by the 403): statistics come back as JSON STRINGS ('350'); raw GetInt64() throws. Tolerant ReadInt64 (ValueKind-first; JsonElement.TryGetInt64 THROWS on strings — type-in, not try-type). Good Dog: ChannelStatsServiceTests.CaptureCurrent_RequestsNoAuditDetails_AndStillParsesTheSnapshot (URL asserts no auditDetails + snapshot parses); YppPullOutTests fixture updated. Recipes for both 403/scope and statistics-strings entered in MyMistakes.md. Also shipped in the same commit (shared PreviewPane.xaml + ai.md): the audio-sync status dot removal from the #77 feedback round (creator: 'what is the point of the status light? Lose it') — IntToSyncBrushConverter deleted with it. verify.sh gate: 0 warnings, 316/316 pass, scope-check clean.
4.2 KiB
TASK 22 — Audio sync offset
Catalog:
TASKS.md— status and requirements live here.
Goal: per-source audio delay compensation to prevent lip-sync drift from USB mics and capture cards.
Status: ✅ Done (shipped TASK 22, 2026-08-31)
- ☑
AudioSyncOffsetMsonMainViewModel(global, default 0, range 0..500 ms) — positive-only: OBS's documented fix delays the audio so it lands on video when it runs ahead; advancing audio would need a video-side delay (out of the audio layer's scope, v1.1+). - ☑ Applied in
AudioMixer— post-mix interleaved-stereo delay via the pureAudioSyncDelayline (Services/Audio/AudioSyncDelay.cs), fed through aFunc<int> syncOffsetMsseam each mix tick. - ☑ UI: compact "SYNC" slider (0..500) on the mic bar. The status dot (green = no-op, amber = offset set) was REMOVED 2026-09-23 (creator, live-launch feedback: "what is the point of the status light? Lose it") — the slider's position + the numeric tooltip carry the state, and
IntToSyncBrushConverterwas deleted with it. Provenance (recorded 2026-09-01 after a creator "I never ordered this" scare): the creator explicitly asked for OBS's delay-filter lip-sync fix BUILT NATIVELY — the feature is his, not AI drift. Its placement (preview-rail vs mic-settings/gear) remains an open design question; do not remove the capability. - ☑ Persisted in
LayoutStore.Settings(Audio.SyncOffsetMs) viaLoadAudioSyncOffsetMs/SaveAudioSyncOffsetMs; saved fromSaveLayoutNow. - ☑ Tests:
AudioSyncDelayTests— zero-delay identity, negative→0 clamp, >500 ms clamp to 500 ms, and 10 ms → 960 interleaved-sample shift. - ⚠ Post-ship regression (found 2026-09-01, first real launch): this task's sync-delay line
_delayedMixwas declared nullable and never initialized — the firstdelayed.Lengthderef NRE'd EVERY live-mix tick, silently killing all live/record audio, hangingAudioPipelineTests, and being mislabeled a "known failure". Fixed in the recording-verification pass (init + null-check + throttled loop errors logged with stack);AudioPipelineTests25/25 green afterward. Lesson recorded in MyMistakes.
Design decisions
-
Global offset first — one setting for all audio sources. Per-source is v1.1+.
-
Signed offset (2026-09-14) — WIDENED from positive-only 0..500 to −500..+500.
The "positive-only / advance needs video-side delay / out of scope" line below is RETIRED. Negative offsets now ADVANCE the audio by eating the head of the live stream (OBS's negative-sync behavior):
AudioMixer.StartLivearms_advanceSamplesRemaining= |N| ms → samples, andLiveLoopAsyncdrops that many samples off the write head. Positive keeps using theAudioSyncDelayline live-reactive. Slider relabelled "AUDIO SYNC",Min="-500", and locked (IsEnabled = IsEditMode) while live or recording — a negative advance can only be armed at go-live, so it must not move mid-session. Clamps:Pre-viewModel+LayoutStore±500;AudioSyncDelaystill clamps negative→0 internally (pure delay line, unchanged). Provenance (2026-09-14): creator-directive — asked for both directions after the ring-backlog fix surfaced the residual (audio can run late too: capture cards, BT, webcams). Regression test:StartLive_NegativeOffset_AdvancesAudio_ByDroppingTheStreamHead. -
Positive-only (delay audio) — the physically-correct direction (audio runs ahead of the video). True "advance" needs a video-side delay and is PERMANENTLY OUT with per-source sync (TASKS.md → "Out of product" — v1.x phrasing retired 2026-09-01).
-
Simple slider — 0 to +500 ms, default 0. No numeric input needed.
-
Visual feedback — "sync OK" status dot when an offset is dialled in.RETIRED 2026-09-23 by creator — the status light added nothing (see item 3); the numeric tooltip already states the offset.
❗ REQUIRED before 1.0 (creator directive 2026-09-14)
A detailed user-doc tutorial on the audio-sync feature (what -500..+500 means, the
clap-calibration recipe both directions, and that it locks while live). docs/ currently
holds only the README image — the tutorial is unstarted. Add it to the 1.0/gold-pass checklist.