Skip to content

Scope ALSA get_state() to Playback channels on mixed Capture/Playback controls#237

Merged
balloob merged 2 commits intomainfrom
copilot/fix-alza-get-state-volume
Apr 28, 2026
Merged

Scope ALSA get_state() to Playback channels on mixed Capture/Playback controls#237
balloob merged 2 commits intomainfrom
copilot/fix-alza-get-state-volume

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

AlsaVolumeController.get_state() could parse the wrong value on mixer elements that expose both Capture and Playback channels, because amixer sget output was not constrained to Playback. This change makes get_state() explicitly read Playback state and locks that behavior with focused tests.

  • Playback-only ALSA state read

    • Updated get_state() to call:
      • amixer -M -c <card> sget <element> playback
    • This aligns read-path behavior with set_state() (already using playback) and avoids capture-line ambiguity in mixed controls.
  • Regression coverage for mixed-channel elements

    • Added a targeted test asserting get_state() invokes sget ... playback.
    • Updated existing command expectation in ALSA controller tests to include the playback qualifier.
proc = await asyncio.create_subprocess_exec(
    "amixer",
    "-M",
    "-c",
    self._card,
    "sget",
    self._element,
    "playback",
    stdout=asyncio.subprocess.PIPE,
    stderr=asyncio.subprocess.PIPE,
)

Copilot AI changed the title [WIP] Fix alsa_volume.py to read correct Playback volume Scope ALSA get_state() to Playback channels on mixed Capture/Playback controls Apr 28, 2026
Copilot AI requested a review from balloob April 28, 2026 13:35
@balloob balloob marked this pull request as ready for review April 28, 2026 13:37
Copilot AI review requested due to automatic review settings April 28, 2026 13:37
@balloob balloob merged commit d4d30c9 into main Apr 28, 2026
3 checks passed
@balloob balloob deleted the copilot/fix-alza-get-state-volume branch April 28, 2026 13:37
@balloob balloob added the bugfix Fixes a bug label Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an ALSA parsing ambiguity by ensuring AlsaVolumeController.get_state() queries only Playback channels on mixer elements that expose both Capture and Playback, and adds regression tests to lock in the intended amixer invocation.

Changes:

  • Update AlsaVolumeController.get_state() to call amixer ... sget <element> playback to avoid mixed-channel ambiguity.
  • Add a focused test asserting get_state() includes the playback qualifier for mixed Capture/Playback controls.
  • Update an existing ALSA controller test’s expected amixer sget arguments to include playback.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sendspin/alsa_volume.py Scopes get_state()’s amixer sget call to Playback channels by appending playback.
tests/test_alsa_volume.py Adds/updates expectations to verify get_state() invokes amixer sget ... playback and remains correct on mixed controls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alsa_volume.py: get_state() reads Capture volume instead of Playback on mixed-channel mixer elements

3 participants