fix: connection issues
This commit is contained in:
+36
-12
@@ -68,14 +68,19 @@ Notes: verified on the FiiO via injected key events (a rotary volume knob may no
|
||||
emit `VOLUME_UP/DOWN` — hardware-dependent). Album art in the notification/session
|
||||
is pending item #5.
|
||||
|
||||
## [ ] 4. Library browse — albums
|
||||
## [x] 4. Library browse — albums
|
||||
|
||||
A screen to browse all albums on the server (artists can come later).
|
||||
Done. `AlbumsScreen` (library icon on the player) lists every album via
|
||||
`list album group albumartist` (`MpdCommands.listAlbums` → `MpdAlbum.listFrom`),
|
||||
sorted by artist then title. Tapping an album replaces the queue and plays it
|
||||
(`MpdClient.playAlbum` = `clear` + `findadd album … albumartist …` + `play`),
|
||||
then returns to the now-playing screen.
|
||||
|
||||
- MPD commands: `list album group albumartist` (or `list album`), and
|
||||
`find album "<name>"` to fetch an album's tracks; add to the queue with
|
||||
`add`/`findadd`. Extend `MpdCommands` + `MpdClient`.
|
||||
- Grid or list of albums → tap to view/queue tracks.
|
||||
- Verified live: 149 albums listed and played correctly on the FiiO.
|
||||
- Placeholder disc icon per row (real art is item #5).
|
||||
- Interaction choice: tap = **replace queue + play** (the direct "play this
|
||||
album" gesture). Could later add a long-press / menu for "add to queue" and an
|
||||
album-detail/track view. Artist browse is a future extension.
|
||||
|
||||
## [ ] 5. Album / artist images
|
||||
|
||||
@@ -88,7 +93,7 @@ Pull artwork for the now-playing track and for the album browse grid.
|
||||
- Needs an image loader + caching. Coil (`io.coil-kt`) is the standard Compose
|
||||
choice; a custom `MpdArtFetcher` could feed it. Dependency → `deps.json` regen.
|
||||
|
||||
## [ ] 6. BUG: idle connection drops after a few minutes → kicked to connect page
|
||||
## [x] 6. BUG: idle connection drops after a few minutes → kicked to connect page
|
||||
|
||||
After a few minutes idling, the app surfaces **"connection closed mid-response"**
|
||||
and falls back to the connect screen. MALP does not do this.
|
||||
@@ -108,8 +113,27 @@ and falls back to the connect screen. MALP does not do this.
|
||||
**auto-reconnect transparently** (re-open connections, re-issue `idle`, resync
|
||||
state) and keep showing the player. Consider a keepalive ping and, for
|
||||
backgrounded playback control, a foreground service / partial wakelock.
|
||||
- PARTIALLY ADDRESSED by item #3: the `mediaPlayback` foreground service now
|
||||
keeps the process/connection alive in the background, which should stop Doze /
|
||||
wifi power-save from tearing the sockets down (the most likely cause). Still
|
||||
worth verifying over a long idle, and adding transparent auto-reconnect +
|
||||
keepalive ping as defense-in-depth (e.g. against MPD `connection_timeout`).
|
||||
- PARTIALLY ADDRESSED by item #3: the `mediaPlayback` foreground service keeps
|
||||
the process/connection alive in the background.
|
||||
|
||||
**FIXED.** Root cause was two-fold: (a) the quiet command connection was reaped
|
||||
by MPD's `connection_timeout`, and (b) the idle loop treated *any* `IOException`
|
||||
(including that reap) as fatal → `Error` → connect page. Plus a Pi-Zero overload
|
||||
angle: volume-key floods + 2-round-trip refreshes. Fixes, all in `MpdClient`
|
||||
/`MpdConnectionManager`/`MpdConnection`:
|
||||
|
||||
- **Keepalive `ping`** every 25s on the command connection — prevents the
|
||||
`connection_timeout` reap and detects a dead socket early.
|
||||
- **Transparent auto-reconnect** (`triggerReconnect`/`reconnectLoop`): a transport
|
||||
drop reopens both sockets in the background (state → `Connecting`, "Connecting…"
|
||||
splash, player stays), retrying with backoff; only after
|
||||
`MAX_RECONNECT_ATTEMPTS` does it surface `Error`. `MpdAckException` is
|
||||
explicitly *not* treated as a connection failure.
|
||||
- **Volume throttle**: `setvol` writes are coalesced through a conflated channel
|
||||
(~1 per 120 ms, latest value) — kills the flood from holding volume keys while
|
||||
keeping accurate accumulation via `pendingVolume`.
|
||||
- **Command-list refresh**: `status`+`currentsong` fetched in one round-trip
|
||||
(`MpdConnection.executeList`, `command_list_ok_begin`).
|
||||
|
||||
Verified on the FiiO: Wi-Fi drop → "Connecting…" → auto-recovers to the player
|
||||
(no connect-page bounce); 6 rapid volume presses = exactly −30, throttled.
|
||||
|
||||
Reference in New Issue
Block a user