Skip to content

Conversation

@p-gentili
Copy link
Collaborator

@p-gentili p-gentili commented Sep 26, 2025

Description

This PR introduces a new utility module in checkbox support to scan and control sources and sinks using both Pipewire and Pulseaudio in a transparent way.

The main functions explains a bit how to use it, but in general:

  1. List only the sinks / sources
  2. Iter on sinks / sources, and control it one by one

It's non trivial to control nodes outside of the iteration, especially with Pipewire: Nodes are ephemeral, and there's no identifier that is guaranteed to survive after changing device profile.

Resolved issues

N/A

Documentation

N/A

Tests

Run it as a script, and check if the sink on your machine changes.

NB: there are sinks that are available but not actually usable: your settings panel might not update the displayed value in this case.

@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

❌ Patch coverage is 92.19713% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.06%. Comparing base (a65231d) to head (533afc7).

Files with missing lines Patch % Lines
...ort/checkbox_support/helpers/audio_server_utils.py 83.71% 30 Missing and 6 partials ⚠️
...x_support/helpers/tests/test_audio_server_utils.py 99.24% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2131      +/-   ##
==========================================
+ Coverage   53.63%   54.06%   +0.43%     
==========================================
  Files         401      403       +2     
  Lines       43116    43603     +487     
  Branches     7990     8058      +68     
==========================================
+ Hits        23127    23576     +449     
- Misses      19174    19205      +31     
- Partials      815      822       +7     
Flag Coverage Δ
checkbox-support 67.28% <92.19%> (+1.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@p-gentili p-gentili changed the title [New] audio utils module (DRAFT) DRAFT: audio utils module (New) Sep 26, 2025
@p-gentili p-gentili force-pushed the audio-utils branch 2 times, most recently from 9f11017 to 93e736d Compare November 12, 2025 09:51
@p-gentili p-gentili changed the title DRAFT: audio utils module (New) Audio server utils module (New) Nov 12, 2025
@p-gentili p-gentili marked this pull request as ready for review November 12, 2025 13:47
Introduces a unified interface for working with PulseAudio and PipeWire
audio servers without requiring deep knowledge of either system.

Features:
- AudioServerUtils factory that auto-detects the running audio server
- PipewireUtils: Full support for PipeWire's device/profile/node hierarchy
- PulseaudioUtils: Support for PulseAudio sink/source management
- Node abstraction representing audio sinks and sources
- Methods to list, iterate, set default, and control volume of audio nodes
- CLI interface for listing and interactively selecting audio nodes

The iterator pattern (iter_sinks/iter_sources) automatically activates
profiles before yielding nodes, making them immediately usable.
Comprehensive test coverage for the audio_server_utils module:

- NodeTests: Basic Node class instantiation
- AudioServerUtilsTests: Factory pattern and server detection
- PipewireUtilsTests: PipeWire-specific functionality including
  pw-dump parsing, device/profile/node handling, and volume control
- PulseaudioUtilsTests: PulseAudio-specific functionality including
  pactl parsing, sink/source management, and volume control
@Hook25 Hook25 self-assigned this Nov 26, 2025
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.

3 participants