Repository navigation
11098 device change fixes - #11446
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change routes audio configuration through Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Preferences
participant PlaybackController
participant Au3AudioDevicesProvider
participant Au3AudioEngine
participant Au3Player
User->>Preferences: change audio configuration
Preferences->>PlaybackController: apply configuration
PlaybackController->>Au3AudioDevicesProvider: apply device or stream setting
Au3AudioDevicesProvider->>Au3AudioEngine: stop and reconfigure monitoring
PlaybackController->>Au3Player: resume playback or retain paused position
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsLinked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/au3audio/internal/au3audiodevicesprovider.cpp (1)
226-249: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winUse RAII for
m_monitoringRestoreDepthto ensure exception safety.If
change()throws an exception or otherwise interrupts the flow,m_monitoringRestoreDepthwill remain incremented, permanently preventing input monitoring from being restored in future operations. Wrapping the depth counter in an RAII guard ensures it is reliably decremented regardless of how the block exits.🛡️ Proposed fix
audioEngine()->stopMonitoring(); - ++m_monitoringRestoreDepth; - change(); - --m_monitoringRestoreDepth; + { + struct DepthGuard { + int& depth; + DepthGuard(int& d) : depth(d) { ++depth; } + ~DepthGuard() { --depth; } + } guard(m_monitoringRestoreDepth); + + change(); + } if (wasMonitoring) {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 5e1ddcb0-c1de-4227-bf4a-c7857d1d3c09
📥 Commits
Reviewing files that changed from the base of the PR and between f08188ca94755025dde5205f4130a8f4f98e1278 and 63a644e75b811f704605bda6f8bf9a3744b242e1.
📒 Files selected for processing (9)
src/au3audio/internal/au3audiodevicesprovider.cppsrc/au3audio/internal/au3audiodevicesprovider.hsrc/au3audio/tests/au3audiodevicesprovider_tests.cppsrc/playback/internal/au3/au3player.cppsrc/playback/internal/playbackcontroller.cppsrc/playback/internal/playbackcontroller.hsrc/playback/iplaybackcontroller.hsrc/playback/tests/playbackcontroller_tests.cppsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
- src/playback/iplaybackcontroller.h
- src/playback/internal/playbackcontroller.h
- src/playback/tests/playbackcontroller_tests.cpp
- src/playback/internal/playbackcontroller.cpp
e05c17e to
5daedc1
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/playback/tests/playbackcontroller_tests.cpp (1)
1108-1114: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winRequire fallback playback instead of only rejecting the stale position.
These tests currently pass when
togglePlay()never callsplay. Assert oneplay(std::nullopt)call while retaining the stale-position prohibition.
src/playback/tests/playbackcontroller_tests.cpp#L1108-L1114: require playback of the fresh selection.src/playback/tests/playbackcontroller_tests.cpp#L1147-L1154: require playback after Select All.src/playback/tests/playbackcontroller_tests.cpp#L1183-L1188: require normal playback after discarding the out-of-range resume.src/playback/tests/playbackcontroller_tests.cpp#L1303-L1308: require normal playback after Stop clears the pending resume.src/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp (1)
259-283: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise the ASIO flag this test claims to cover.
Stage
falsefrom an appliedtruevalue to cover the important engaged-optional<bool>false path.Proposed test addition
TEST_F(CommonAudioApiConfigurationModelTests, Apply_NonStreamSettings_GoDirectlyToTheProvider) { + ON_CALL(*m_provider, asioUseDeviceSampleRate()) + .WillByDefault(Return(true)); + m_model->defaultSampleRateValueSelected(48000); m_model->defaultSampleFormatSelected("16-bit"); m_model->setAutomaticCompensationEnabled(true); + m_model->setAsioUseDeviceSampleRate(false); EXPECT_CALL(*m_provider, setDefaultSampleRate(48000)).Times(1); EXPECT_CALL(*m_provider, setDefaultSampleFormat("16-bit")).Times(1); EXPECT_CALL(*m_provider, setAutomaticCompensationEnabled(true)).Times(1); + EXPECT_CALL(*m_provider, setAsioUseDeviceSampleRate(false)).Times(1);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: cb18bede-35c0-499c-a765-96f84a4d864d
📥 Commits
Reviewing files that changed from the base of the PR and between 63a644e75b811f704605bda6f8bf9a3744b242e1 and 5daedc13d4b01a27fc9f9bc938d85bbca362fffa.
📒 Files selected for processing (31)
CMakeLists.txtsrc/au3audio/CMakeLists.txtsrc/au3audio/internal/au3audiodevicesprovider.cppsrc/au3audio/internal/au3audiodevicesprovider.hsrc/au3audio/internal/au3audioengine.cppsrc/au3audio/internal/au3audioengine.hsrc/au3audio/tests/CMakeLists.txtsrc/au3audio/tests/au3audiodevicesprovider_tests.cppsrc/au3audio/tests/mocks/audioenginemock.hsrc/audio/iaudiodevicesprovider.hsrc/audio/iaudioengine.hsrc/audio/tests/mocks/audiodevicesprovidermock.hsrc/playback/internal/au3/au3player.cppsrc/playback/internal/au3/au3player.hsrc/playback/internal/playbackcontroller.cppsrc/playback/internal/playbackcontroller.hsrc/playback/iplaybackcontroller.hsrc/playback/iplayer.hsrc/playback/tests/environment.cppsrc/playback/tests/mocks/playbackcontrollermock.hsrc/playback/tests/mocks/playermock.hsrc/playback/tests/playbackcontroller_tests.cppsrc/preferences/CMakeLists.txtsrc/preferences/qml/Audacity/Preferences/AudioPreferencesPage.qmlsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cppsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.hsrc/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qmlsrc/preferences/qml/Audacity/Preferences/internal/BufferAndLatencySection.qmlsrc/preferences/qml/Audacity/Preferences/internal/SampleRateSection.qmlsrc/preferences/tests/CMakeLists.txtsrc/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp
💤 Files with no reviewable changes (2)
- src/preferences/qml/Audacity/Preferences/internal/SampleRateSection.qml
- src/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qml
🚧 Files skipped from review as they are similar to previous changes (14)
- src/au3audio/internal/au3audioengine.h
- CMakeLists.txt
- src/au3audio/CMakeLists.txt
- src/playback/iplayer.h
- src/au3audio/tests/CMakeLists.txt
- src/playback/iplaybackcontroller.h
- src/playback/tests/mocks/playermock.h
- src/playback/tests/environment.cpp
- src/playback/internal/au3/au3player.h
- src/au3audio/tests/mocks/audioenginemock.h
- src/preferences/qml/Audacity/Preferences/internal/BufferAndLatencySection.qml
- src/playback/internal/playbackcontroller.h
- src/playback/internal/playbackcontroller.cpp
- src/au3audio/internal/au3audiodevicesprovider.cpp
5daedc1 to
0c2268f
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp (1)
74-76: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReorder fixture members to ensure the system under test is destroyed before its dependencies.
In C++, class members are destroyed in the reverse order of their declaration. Currently,
m_model(the system under test) is declared before its dependencies (m_providerandm_controller), meaning it will be destroyed last.If
m_modelever accesses these dependencies during its destruction (for example, to unregister event listeners or observers), it could lead to a use-after-free crash since the mocks would have already been destroyed. Declaring the dependencies first prevents this potential risk.♻️ Proposed refactor
- std::unique_ptr<CommonAudioApiConfigurationModel> m_model; std::shared_ptr<audio::AudioDevicesProviderMock> m_provider; std::shared_ptr<playback::PlaybackControllerMock> m_controller; + std::unique_ptr<CommonAudioApiConfigurationModel> m_model;
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 43ca653a-ecc4-469c-943d-68f32589e282
📥 Commits
Reviewing files that changed from the base of the PR and between 5daedc13d4b01a27fc9f9bc938d85bbca362fffa and 0c2268f9624728eb2c8d78d417d17902a25a8398.
📒 Files selected for processing (6)
CMakeLists.txtsrc/playback/tests/mocks/playbackcontrollermock.hsrc/preferences/CMakeLists.txtsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.hsrc/preferences/tests/CMakeLists.txtsrc/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
- src/preferences/CMakeLists.txt
- CMakeLists.txt
- src/preferences/tests/CMakeLists.txt
- src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.h
- src/playback/tests/mocks/playbackcontrollermock.h
0c2268f to
22403ff
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/preferences/tests/commonaudioapiconfigurationmodel_tests.cpp (1)
154-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert
withSingleStreamRestart(_)is skipped when nothing stream-affecting changes.Both tests confirm individual setters aren't called but don't assert the batch scope itself is skipped. Per the design intent (non-stream settings "bypass the playback controller", no-edit apply pushes nothing), a regression that wraps these no-op paths in
withSingleStreamRestart()anyway — causing a spurious, audible stream interruption — would still pass.♻️ Proposed additions
TEST_F(CommonAudioApiConfigurationModelTests, Apply_WithoutEdits_PushesNothing) { //! [THEN] No setter is called at all + EXPECT_CALL(*m_controller, withSingleStreamRestart(_)).Times(0); EXPECT_CALL(*m_controller, setAudioApi(_)).Times(0);TEST_F(CommonAudioApiConfigurationModelTests, Apply_NonStreamSettings_GoDirectlyToTheProvider) { //! [THEN] They are pushed to the provider, not through the stream restart + EXPECT_CALL(*m_controller, withSingleStreamRestart(_)).Times(0); EXPECT_CALL(*m_provider, setDefaultSampleRate(48000)).Times(1);Also applies to: 289-307
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 430c9abf-6596-4d2d-b725-4997944ead6a
📥 Commits
Reviewing files that changed from the base of the PR and between 0c2268f9624728eb2c8d78d417d17902a25a8398 and 22403ff9cb469c025a96794aae12b4084b73fd3f.
📒 Files selected for processing (33)
CMakeLists.txtsrc/au3audio/CMakeLists.txtsrc/au3audio/internal/au3audiodevicesprovider.cppsrc/au3audio/internal/au3audiodevicesprovider.hsrc/au3audio/internal/au3audioengine.cppsrc/au3audio/internal/au3audioengine.hsrc/au3audio/tests/CMakeLists.txtsrc/au3audio/tests/au3audiodevicesprovider_tests.cppsrc/au3audio/tests/mocks/audioenginemock.hsrc/audio/iaudiodevicesprovider.hsrc/audio/iaudioengine.hsrc/audio/tests/mocks/audiodevicesprovidermock.hsrc/playback/internal/au3/au3player.cppsrc/playback/internal/au3/au3player.hsrc/playback/internal/playbackcontroller.cppsrc/playback/internal/playbackcontroller.hsrc/playback/iplaybackcontroller.hsrc/playback/iplayer.hsrc/playback/playbacktypes.hsrc/playback/tests/environment.cppsrc/playback/tests/mocks/playbackcontrollermock.hsrc/playback/tests/mocks/playermock.hsrc/playback/tests/playbackcontroller_tests.cppsrc/preferences/CMakeLists.txtsrc/preferences/qml/Audacity/Preferences/AudioPreferencesPage.qmlsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cppsrc/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.hsrc/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qmlsrc/preferences/qml/Audacity/Preferences/internal/BufferAndLatencySection.qmlsrc/preferences/qml/Audacity/Preferences/internal/SampleRateSection.qmlsrc/preferences/tests/CMakeLists.txtsrc/preferences/tests/commonaudioapiconfigurationmodel_tests.cppsrc/record/internal/au3/au3record.cpp
💤 Files with no reviewable changes (1)
- src/preferences/qml/Audacity/Preferences/internal/AudioApiSection.qml
🚧 Files skipped from review as they are similar to previous changes (19)
- src/au3audio/CMakeLists.txt
- src/playback/tests/environment.cpp
- src/preferences/qml/Audacity/Preferences/AudioPreferencesPage.qml
- CMakeLists.txt
- src/playback/tests/mocks/playermock.h
- src/preferences/CMakeLists.txt
- src/preferences/tests/CMakeLists.txt
- src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.h
- src/playback/tests/mocks/playbackcontrollermock.h
- src/audio/iaudiodevicesprovider.h
- src/preferences/qml/Audacity/Preferences/internal/BufferAndLatencySection.qml
- src/preferences/qml/Audacity/Preferences/internal/SampleRateSection.qml
- src/playback/iplayer.h
- src/audio/tests/mocks/audiodevicesprovidermock.h
- src/playback/internal/playbackcontroller.h
- src/playback/tests/playbackcontroller_tests.cpp
- src/preferences/qml/Audacity/Preferences/commonaudioapiconfigurationmodel.cpp
- src/au3audio/internal/au3audiodevicesprovider.cpp
- src/playback/internal/playbackcontroller.cpp
a32772b to
679f9f7
Compare
679f9f7 to
8581543
Compare
| // Includes transitional busy/inactive stream states. | ||
| virtual std::optional<AudioStreamDescriptor> currentStream() const = 0; | ||
|
|
||
| struct StartStreamOptions { |
There was a problem hiding this comment.
Nit and not for now.
It is odd for me we have a struct StartStreamOptions that has only a subset of the fields in AudioIOStartStreamOptions.
IMO we should have a struct compatible with the later.
Probably with some default constructor that already populate it just as GetDefaultOptions and some helpers to convert it to AudioIOStartStreamOptions
| if (pStartTime && *pStartTime >= t1) { | ||
| // Starting at/past the region end extends to the project end. | ||
| const std::optional<double> streamStartTime = opts.streamStartTime.has_value() ? opts.streamStartTime : pStartTime; | ||
| if (streamStartTime && *streamStartTime >= t1) { |
There was a problem hiding this comment.
Nit (personal taste). IMO using streamStartTime.value() is more intuitive than this dereference syntax
| @@ -30,12 +30,8 @@ class PlaybackController : public IPlaybackController, public audio::IAudioStrea | |||
| { | |||
| public: | |||
| muse::GlobalInject<au::playback::IPlaybackConfiguration> playbackConfiguration; | |||
| <<<<<<< HEAD | |||
There was a problem hiding this comment.
All other commits are completely broken (won't compile) due this thing here.
I don't know if worth it to fix this where this was inserted.
Move the stream start override into PlayTracksOptions Extend playback to project end when the resume position is at/past the region end Allow starting the playback stream at an explicit position
…ller This allows different instances to stop and resume the playback when changing audio device settings
…e iterations when device changed during active playback
Fix playback tests after rebase Document deliberate suspension and sample-rate policies
8581543 to
38c1c9f
Compare
Original PR: #11245
Resolves: #11098
Resolves: #9443
Resolves: #11102
Recommended:
QA: