Skip to content

11389 add system default for playback and recording devices. - #11428

Merged
embarc-gabriel merged 20 commits into
audacity:masterfrom
embarc-gabriel:11389-error-when-no-record-device-available
Aug 3, 2026
Merged

embarc-gabriel merged 20 commits into
audacity:masterfrom
embarc-gabriel:11389-error-when-no-record-device-available

Conversation

@embarc-gabriel

@embarc-gabriel embarc-gabriel commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Resolves: #11389
Resolves: #11394

Adds a "system default" option for playback and recording devices.
Also return a meaningful error if there is no device available and the user tries to record audio.

This PR does not implement refresh on device add/remove, UI actions enable/disable while recording and playback or other tweaks. These implementations will be included on follow up tickets.

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • New entry on the device list (default)
  • Auto refresh the device list when connecting a Bluetooth device, for example.
  • Toast notification when connecting and disconnecting a device if this device is now the new default
  • Testflow test cases have been run

Known limitations: (to confirm and add follow up tickets, please)

  • The device list is only updated after the stream is stopped. During playback or recording we won't see the toast until the operation is finished and we can face issues if the device we are using is not present.
  • Pause does not trigger a refresh on the device list.

@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch from 4bbc2af to fab9b42 Compare July 13, 2026 14:20
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Audio device selection now supports an unset state representing “System default.” Provider APIs use optional device names, host-specific defaults are resolved through DeviceManager, and rescans revalidate selections. Platform listeners detect system device changes, while preferences and toolbar menus expose system-default choices. Audio startup rejects invalid or input-incapable devices, and recording reports a dedicated error when no recording device is available.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AudioDeviceUI
  participant PlaybackController
  participant Au3AudioDevicesProvider
  participant DeviceManager
  User->>AudioDeviceUI: choose System default
  AudioDeviceUI->>PlaybackController: dispatch default-device action
  PlaybackController->>Au3AudioDevicesProvider: clear selected device
  Au3AudioDevicesProvider->>DeviceManager: resolve host-specific default
  DeviceManager-->>Au3AudioDevicesProvider: return default device
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning It also adds device-refresh listeners, UI toast/revalidation flows, and test/build scaffolding that were explicitly deferred. Move refresh/listener/UI behavior into follow-up PRs, or trim this change to the system-default selection and recording error only.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the system-default device selection and a no-recording-device error, matching the linked issue goals.
Title check ✅ Passed The title is concise and clearly summarizes the main change: adding a system default option for playback and recording devices.
Description check ✅ Passed The description covers the issue references, motivation, scope, checkboxes, QA notes, and known limitations, so it is mostly complete.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@embarc-gabriel

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@embarc-gabriel

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 012fb6bc-26f1-47a1-b7ff-1206685e0d71

📥 Commits

Reviewing files that changed from the base of the PR and between 425fd3c and fab9b42b22876b29d5873ea30f8379733b73ca75.

📒 Files selected for processing (11)
  • au3/libraries/au3-audio-devices/AudioIOBase.cpp
  • au3/libraries/au3-audio-io/AudioIO.cpp
  • src/au3audio/internal/au3audiodevicesprovider.cpp
  • src/au3audio/internal/au3audiodevicesprovider.h
  • src/audio/iaudiodevicesprovider.h
  • src/playback/internal/playbackcontroller.cpp
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
  • src/projectscene/view/toolbars/audiosetupcontextmenumodel.cpp
  • src/record/internal/au3/au3record.cpp
  • src/record/internal/au3/au3record.h
  • src/record/recorderrors.h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0c69fcac-8dab-46c3-b895-daac0c2073aa

📥 Commits

Reviewing files that changed from the base of the PR and between 0b3fd4e80eda25b33d77c5d9676888f0bd2f882b and 8b27d7cec5178b2dde91f42d9bd56e711c70edbe.

📒 Files selected for processing (33)
  • CMakeLists.txt
  • SetupConfigure.cmake
  • src/au3audio/CMakeLists.txt
  • src/au3audio/au3audiomodule.cpp
  • src/au3audio/au3audiomodule.h
  • src/au3audio/iau3devicemanager.h
  • src/au3audio/internal/au3audiodevicesprovider.cpp
  • src/au3audio/internal/au3audiodevicesprovider.h
  • src/au3audio/internal/au3devicemanager.cpp
  • src/au3audio/internal/au3devicemanager.h
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/stub/stubsystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.h
  • src/au3audio/isystemaudiodeviceslistener.h
  • src/au3audio/tests/CMakeLists.txt
  • src/au3audio/tests/au3audiodevicesprovider_tests.cpp
  • src/au3audio/tests/environment.cpp
  • src/au3audio/tests/mocks/au3devicemanagerfake.h
  • src/audio/iaudiodevicesprovider.h
  • src/audio/tests/mocks/audiodevicesprovidermock.h
  • src/audio/tests/mocks/audioenginemock.h
  • src/playback/internal/playbackcontroller.cpp
  • src/playback/internal/playbackcontroller.h
  • src/playback/tests/playbackcontroller_tests.cpp
  • src/preferences/CMakeLists.txt
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
  • src/preferences/tests/CMakeLists.txt
  • src/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp
  • src/projectscene/view/toolbars/audiosetupcontextmenumodel.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/audio/iaudiodevicesprovider.h
  • src/projectscene/view/toolbars/audiosetupcontextmenumodel.cpp
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
  • src/au3audio/internal/au3audiodevicesprovider.h
  • src/au3audio/internal/au3audiodevicesprovider.cpp

@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch 2 times, most recently from 1a4169b to f988236 Compare July 20, 2026 15:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9d78f323-eb8d-4b23-9ceb-2ac0c15e2a86

📥 Commits

Reviewing files that changed from the base of the PR and between 4db113a9a928beb8c86240fcf5b520712971ef56 and f98823686aa3a2f0d24a0232441e79f0ce549331.

📒 Files selected for processing (46)
  • CMakeLists.txt
  • SetupConfigure.cmake
  • au3/libraries/au3-audio-devices/AudioIOBase.cpp
  • au3/libraries/au3-audio-devices/DeviceManager.cpp
  • au3/libraries/au3-audio-io/AudioIO.cpp
  • buildscripts/ci/linux/setup.sh
  • src/au3audio/CMakeLists.txt
  • src/au3audio/au3audiomodule.cpp
  • src/au3audio/au3audiomodule.h
  • src/au3audio/iau3devicemanager.h
  • src/au3audio/internal/au3audiodevicesprovider.cpp
  • src/au3audio/internal/au3audiodevicesprovider.h
  • src/au3audio/internal/au3audioengine.cpp
  • src/au3audio/internal/au3audioengine.h
  • src/au3audio/internal/au3audioiolistener.h
  • src/au3audio/internal/au3devicemanager.cpp
  • src/au3audio/internal/au3devicemanager.h
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/stub/stubsystemaudiodeviceslistener.h
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.cpp
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.h
  • src/au3audio/isystemaudiodeviceslistener.h
  • src/au3audio/tests/CMakeLists.txt
  • src/au3audio/tests/au3audiodevicesprovider_tests.cpp
  • src/au3audio/tests/environment.cpp
  • src/au3audio/tests/mocks/au3devicemanagerfake.h
  • src/audio/iaudiodevicesprovider.h
  • src/audio/iaudioengine.h
  • src/audio/tests/mocks/audiodevicesprovidermock.h
  • src/audio/tests/mocks/audioenginemock.h
  • src/playback/internal/playbackcontroller.cpp
  • src/playback/internal/playbackcontroller.h
  • src/playback/tests/playbackcontroller_tests.cpp
  • src/preferences/CMakeLists.txt
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.h
  • src/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qml
  • src/preferences/tests/CMakeLists.txt
  • src/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp
  • src/projectscene/view/toolbars/audiosetupcontextmenumodel.cpp
  • src/record/internal/au3/au3record.cpp
  • src/record/internal/au3/au3record.h
  • src/record/recorderrors.h
🚧 Files skipped from review as they are similar to previous changes (38)
  • src/record/internal/au3/au3record.h
  • src/au3audio/tests/CMakeLists.txt
  • src/au3audio/internal/platform/stub/stubsystemaudiodeviceslistener.h
  • src/au3audio/internal/au3devicemanager.cpp
  • src/au3audio/iau3devicemanager.h
  • src/preferences/CMakeLists.txt
  • src/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qml
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.h
  • src/au3audio/isystemaudiodeviceslistener.h
  • CMakeLists.txt
  • buildscripts/ci/linux/setup.sh
  • src/preferences/tests/CMakeLists.txt
  • src/au3audio/tests/mocks/au3devicemanagerfake.h
  • src/au3audio/tests/environment.cpp
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.h
  • src/au3audio/internal/au3devicemanager.h
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.h
  • src/au3audio/CMakeLists.txt
  • au3/libraries/au3-audio-devices/AudioIOBase.cpp
  • src/au3audio/internal/platform/macos/macossystemaudiodeviceslistener.cpp
  • src/record/recorderrors.h
  • src/au3audio/internal/platform/linux/linuxsystemaudiodeviceslistener.cpp
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.h
  • src/projectscene/view/toolbars/audiosetupcontextmenumodel.cpp
  • au3/libraries/au3-audio-io/AudioIO.cpp
  • src/au3audio/au3audiomodule.h
  • au3/libraries/au3-audio-devices/DeviceManager.cpp
  • SetupConfigure.cmake
  • src/playback/internal/playbackcontroller.cpp
  • src/playback/tests/playbackcontroller_tests.cpp
  • src/au3audio/internal/platform/windows/windowssystemaudiodeviceslistener.cpp
  • src/playback/internal/playbackcontroller.h
  • src/audio/tests/mocks/audiodevicesprovidermock.h
  • src/au3audio/au3audiomodule.cpp
  • src/au3audio/internal/au3audiodevicesprovider.h
  • src/audio/iaudiodevicesprovider.h
  • src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
  • src/au3audio/internal/au3audiodevicesprovider.cpp

@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch from f988236 to bc74ce0 Compare July 21, 2026 13:25
@chinakov

Copy link
Copy Markdown
Contributor
  • On Windows, if you disconnect a device, Audacity 4 won't show any toast notification, same goes for connecting devices. Furthermore, if playback was initiated, and the device got disconnected, the playback won't be able to re-initialize, play button literally doesn't start playback.
  • Rescanning audio devices does not work at all on Windows

on macOS:

Start playback
Connect bluetooth headphones or any other audio device
Re-scan audio devices
Switch to newly connected device
Start playback again
Observe no playback, even after pressing stop

@embarc-gabriel

Copy link
Copy Markdown
Contributor Author

@chinakov the error you described on macOS seems to be related to this ticket here: #11102

@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch 3 times, most recently from 733f50f to c37b09c Compare July 29, 2026 11:59
@luapmartin
luapmartin self-requested a review July 29, 2026 13:34
@embarc-gabriel

Copy link
Copy Markdown
Contributor Author

@chinakov can you test it again?

@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch 2 times, most recently from eff483d to f7fa789 Compare August 3, 2026 10:43
embarc-gabriel and others added 3 commits August 3, 2026 08:24
GetInputDevicePaIndex/GetOutputDevicePaIndex initialize the
DeviceManager on first use, but GetDefaultDevice did not. With an empty
device preference the Pa-index lookup that used to trigger Init() is
skipped, so an early getPlayDevIndex/getRecordDevIndex call could
iterate empty device maps and silently fall through to the global
PortAudio default of a possibly different host API.
luapmartin and others added 15 commits August 3, 2026 08:24
The device comboboxes used the translated 'System default' display
string as the sentinel for the default-device entry, so a real device
carrying that name (or colliding with the translation) could never be
selected. Use index-based selection like the audio setup context menu,
with entry 0 being 'System default'.

This also makes the empty state consistent: with no devices for the
selected API the list is empty and the current index is now -1, instead
of a current value that was absent from the combo's model.
Cover CommonAudioApiConfigurationModel's index-based device selection:
list composition with the leading 'System default' entry, index mapping
(including the empty-list and unknown-device cases), selection
forwarding to the devices provider, and the case of a real device named
'System default', which must stay distinguishable from the default
entry. Also verify that provider notifications are forwarded as
property-change signals.

Introduces a reusable gmock for IAudioDevicesProvider.
Expose the resolved system default device names on
IAudioDevicesProvider and label the default entry
'System default: <device>' in the preferences comboboxes and the
audio setup menu, so users can see which device will actually be
used.
Add ISystemAudioDevicesListener with a macOS implementation that
watches CoreAudio for device list changes and for changes of the
system default input/output device (e.g. via Audio MIDI Setup or
unplugging a headset), debounced into a single notification.

When the system devices change, the devices provider rescans
automatically so the device list and the resolved system default stay
up to date; the rescan is deferred until the stream finishes when
audio is running, since rescanning restarts PortAudio. When the
rescan changes the device actually in use, the provider reports the
new device through usedInputDeviceChanged/usedOutputDeviceChanged.

Other platforms keep a stub listener (no automatic detection).
When a system-side device change (default device switched in the OS,
device unplugged) causes the playback or recording device in use to
change, show a toast telling the user which device is now used.
Windows: an IMMNotificationClient registered with the WASAPI device
enumerator reports device add/remove/state changes and default-device
switches; notifications arrive on a WASAPI thread and are marshalled
to the main thread and debounced, like the macOS listener.

Linux: a udev monitor on the 'sound' subsystem watched through a
QSocketNotifier detects devices being plugged and unplugged. Default
device changes inside the sound server (PulseAudio/PipeWire) are not
visible to udev; the stub is kept when libudev is not available at
configure time.
Needed so the udev-based system audio device change detection is
actually compiled in CI instead of silently falling back to the stub.
@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch from f7fa789 to 1d6a7b0 Compare August 3, 2026 11:24
@embarc-gabriel
embarc-gabriel force-pushed the 11389-error-when-no-record-device-available branch from 1d6a7b0 to d6273b5 Compare August 3, 2026 11:40
@embarc-gabriel
embarc-gabriel merged commit 0c562b2 into audacity:master Aug 3, 2026
17 checks passed
@embarc-gabriel
embarc-gabriel deleted the 11389-error-when-no-record-device-available branch August 28, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants