audioplayer/ai/todo.md
2026-04-29 06:57:46 +03:00

2.9 KiB

Todo / scratch

What works now

  • Login → server hits /Users/AuthenticateByName, token+user_id persisted to ~/.config/player/config.json
  • Subsequent launches skip login, jump straight to library
  • Library view: 3 columns (artists / albums / tracks), scrollable, click-to-drill
  • All HTTP is asynchttp_submit queues a worker thread; http_pump() runs once per frame and fires callbacks on the main thread. UI no longer freezes during fetches or downloads.
  • MP3 + FLAC playback via vendored dr_mp3.h / dr_flac.h (compiled to modules/audio_decoders/linux/decoders.abuild.jai auto-rebuilds when the .c source is newer). Decoded to s16 PCM and handed to Sound_Player as Sound_Data.LINEAR_SAMPLE_ARRAY.
  • OGG + WAV continue through Sound.load_audio_data (Sound_Player's native path).
  • Click a track → downloads (async) → decodes → plays. Auto-advance via Sound_Player's release_asset callback firing track_finished.
  • Pause/resume via user_volume_scale mute trick (still not a real pause)
  • Now-playing screen with title/artist/album, transport buttons, scrub bar
  • Logout button on library top-right clears config.json

Known stubs / rough edges

  • Memory leak: each played track leaks its decoded PCM buffer (~50 MB for a 5-min FLAC). The release_asset callback should call decoder_free for MP3/FLAC paths and free for OGG/WAV — currently it only flips track_finished. Track allocation type per-Sound_Data so the release knows which allocator to use.
  • audio_toggle_pause is volume-mute, not real pause — cursor keeps advancing
  • No real seek (scrub bar is read-only)
  • Image cache never evicts — hold for thousands of items but unbounded over a long session (low priority)
  • Failed image fetches stay marked failed forever; no retry. Often that's right (item has no art) but transient network errors should retry once
  • gfx/shaders.jai is still Simp.immediate_quad (mirrored bars + bass pulse, but no GLSL fragment shader yet)
  • client.jai still has the old sync http_get/http_post and Http_Response / build_auth_header — async.jai uses build_auth_header so the helpers stay, but the sync wrappers are dead code now
  • Stream URL /Audio/{id}/stream returns the original file. If the original is something exotic (Opus, AAC, etc.) it'll fail. Could fall back to /Audio/{id}/universal with audioCodec=mp3 or similar to force-transcode for unsupported formats.

Next likely tasks (in rough order)

  1. Free the decoded buffer when the stream ends (fix the leak)
  2. Fetch primary image per album, decode with stb_image, upload as Simp.Texture, render in album rows + as backdrop on now-playing
  3. Real FFT (dr_libs author's work? or kissfft) hooked to Sound_Player's mixed output buffer
  4. Custom GLSL fragment shader for the visualizer (replaces the bar stack)
  5. Album-level "play all" button in the album column
  6. Real per-stream pause + seek
  7. Search bar above artists column