feat(audio): T-0.3 spike lolos — engine oto v3.5.1 async + fallback anggun (F-024 awal)

This commit is contained in:
oxpoe committed 2026-10-15 06:59:48 +07:00
1 parent 3b4bbf09bc
commit b8d2595ca9
20 files changed
+497 -10

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@ tersedia atribusinya dari menu **Tentang** di aplikasi.
| Aset | Sumber | Lisensi | Tanggal | Status | File target |
|---|---|---|---|---|---|
| Palet Catppuccin (Mocha/Latte) | https://github.com/catppuccin/catppuccin | MIT | — | planned (Phase 1) | `internal/ui/theme/catppuccin.go` |
| Efek suara UI (click, modal, notif, error) | Kenney Interface Sounds — https://kenney.nl/assets/interface-sounds | CC0 1.0 | — | pending (T-0.6) | `internal/audio/assets/*.wav` |
| Efek suara UI — placeholder (8 WAV, generated) | buatan sendiri (script sinus, no external) | ikut lisensi tia | 2026-10-15 | dipakai sementara (T-0.3) | `internal/audio/assets/*.wav` |
| Efek suara UI final (click, modal, notif, error) | Kenney Interface Sounds — https://kenney.nl/assets/interface-sounds | CC0 1.0 | — | pending (T-0.6) | `internal/audio/assets/*.wav` |
| Logo ASCII `tia` | buatan sendiri | ikut lisensi tia | 2026-10 | planned (Phase 1) | `internal/ui/animation/logo.go` |
| Ikon/glyph | Unicode standar (●, ○, ▶, ⟳, ✔, ⚠, ✕) | bebas | 2026-10 | dipakai | di kode UI |
+59
View File
@@ -0,0 +1,59 @@
# Spike T-0.3 — Audio (oto v3.5.1, CGO_ENABLED=0)
> Status: ✅ **LOLOS** · Tanggal: 2026-10-15 · Mesin: Linux (PipeWire + pipewire-pulse aktif, `/dev/snd` tersedia)
## Tujuan (PRD Phase 0)
Buktikan: suara bisa diputar dari binary `CGO_ENABLED=0`; init audio tidak memblok startup;
degradasi anggun tanpa audio device; ukur latensi.
## Cara menjalankan ulang
```bash
# Skenario 1 — live (butuh PulseAudio/PipeWire)
TIA_AUDIO_SPIKE=1 go test ./internal/audio/ -run TestEngineSpike -v -count=1
# Skenario 2 — pulse rusak → fallback ALSA
TIA_AUDIO_SPIKE=1 PULSE_SERVER=unix:/nonexistent go test ./internal/audio/ -run TestEngineSpike -v -count=1
# Skenario 3 — pulse + ALSA rusak → degradasi total (tidak boleh panic)
TIA_AUDIO_SPIKE=1 PULSE_SERVER=unix:/nonexistent ALSA_CONFIG_PATH=/nonexistent/asound.conf \
go test ./internal/audio/ -run TestEngineSpike -v -count=1
```
## Hasil
| # | Skenario | `New()` return | Init + ready | `Play()` return | Status |
|---|---|---|---|---|---|
| 1 | Live (PipeWire/pulse socket) | **1.5 µs** | **13.3 ms** | **5.7 – 15.7 µs** | `siap` ✅ |
| 2 | Pulse rusak → fallback ALSA | 3.1 µs | 26.1 ms | 7 – 12 µs | `siap` (via ALSA) ✅ |
| 3 | Pulse + ALSA rusak | 2.1 µs | 0.4 ms (gagal cepat) | no-op | `gagal: ...` tanpa panic ✅ |
- Binary **6.7 MB** (`CGO_ENABLED=0`), aset 8 WAV embedded = **128 KB** (budget PRD < 2 MB ✓).
- Target PRD: startup < 500 ms → audio init async hanya **1.5 µs** di jalur startup ✓;
latensi suara < 100 ms → pemanggilan `Play()` ~10 µs, latency terdengar mengikuti buffer device.
- TUI menampilkan status engine live: `audio: menyiapkan…` → `siap` setelah redraw pertama.
## Temuan penting
1. **`purego` (dipakai driver ALSA oto) membuat binary link dinamis ke glibc.**
Uji kontrol: hello-world `CGO_ENABLED=0` = `statically linked` murni; begitu oto ikut
di-compile muncul `libc.so.6`, `libdl`, `libpthread`. Artinya: tetap **satu file & tanpa
cgo**, tapi belum `statically linked` penuh. **Alpine/musl belum terverifikasi** → catat
sebagai risiko; jalur keluar bila perlu: build varian tanpa driver ALSA (pulse-only).
2. **Fallback berantai terbukti**: PulseAudio (pure-Go) → ALSA (purego dlopen `libasound.so.2`)
→ error jelas. Pesan error oto ditampilkan apa adanya (sesuai F-023; penjelasan i18n menyusul).
3. Auto-mute SSH diuji di unit test (`SSH_CONNECTION` → `muted`), belum diuji di sesi SSH asli.
## Batasan (jujur)
- Latensi *terdengar* tidak diukur programatik (butuh loopback/ears) — yang diukur waktu init
& waktu `Play()` kembali. Buffer device oto masih default; bila klik terasa delay di hardware
nyata, set `BufferSize` (Phase 1).
- Belum diuji di macOS, WSL2, dan sesi SSH asli.
## Status follow-up
- [ ] Ganti aset placeholder dengan Kenney CC0 (T-0.6)
- [ ] Toggle suara/volume langsung dari layar Pengaturan tanpa restart (Phase 1, F-024)
- [ ] `tia-love doctor` menampilkan status audio (Phase 1)