Skip to content

refactor(playback): separate state and commands from the terminal - #140

Closed
aRustyDev wants to merge 10 commits into
talwat:mainfrom
aRustyDev:stack/1/decouple-playback-core
Closed

aRustyDev wants to merge 10 commits into
talwat:mainfrom
aRustyDev:stack/1/decouple-playback-core

Conversation

@aRustyDev

@aRustyDev aRustyDev commented Oct 30, 2026 •

Copy link
Copy Markdown

TL;DR

Separate playback from terminal setup and rendering so additional frontends can share one playback session.

Important

#blocked-by #139 (which is blocked by #138)

Please wait for #138 and #139 to merge before reviewing this PR. The Files changed tab includes their configuration and testing work because this PR targets main. After they merge, I’ll rebase this branch so the diff contains only the playback-core refactor.

#blocking #142

Incremental core diff for reference.

Changes

  • Move session setup, background tasks, and command routing into Application.
  • Give the player a command handler, neutral playback state, and broadcast updates. Expose volume, position, pause state, and rate through a read-only playback view.
  • Make the terminal and native adapters consume that boundary. Preserve the terminal layout, Linux MPRIS, Windows SMTC, and Linux MPRIS operation with the terminal disabled.
  • Add command-routing, ordered state-update, volume/rate, and terminal-rendering regression tests. Extend mutation coverage to the player.
  • Document live playback views versus copied metadata, receiver lifetime, update ordering, and command outcomes so adapters can use the boundary correctly.
flowchart LR
    T[Terminal input] --> A[Application commands]
    N[MPRIS / SMTC commands] --> A
    A --> P[Player]
    P --> U[Playback state and updates]
    U --> V[Terminal and native adapters]
Loading

Why this approach

The player currently creates and owns the terminal UI and platform controls. Adding another frontend there would tie playback to more UI setup and lifecycle rules.

Moving composition into Application keeps one player and one command path. Read-only state lets adapters observe playback without giving them direct control of the audio sink. A separate player per frontend would risk conflicting sessions; a generic frontend/plugin framework would add abstraction before it is needed. This change keeps the existing concrete adapters and feature gates.

Validation

55 default Cargo tests passed on macOS. Formatting, default/no-default Nextest, curated feature checks, and mutation inventories passed. Native Linux MPRIS suites passed with and without defaults. Private-item documentation passes with broken rustdoc links denied. Tests render audio in memory; live audio/D-Bus integration and native Windows tests were not run locally.

@aRustyDev aRustyDev changed the title Decouple the playback core from frontends Separate playback state and commands from the terminal Oct 30, 2026
@aRustyDev aRustyDev changed the title Separate playback state and commands from the terminal refactor(playback): separate state and commands from the terminal Oct 30, 2026
@aRustyDev
aRustyDev force-pushed the stack/1/decouple-playback-core branch from 2c39a6b to 4018f1f Compare October 30, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants