Repository navigation
Add ASIO support [audacity3] - #11690
Conversation
📝 WalkthroughWalkthroughThe change enables Windows ASIO support by default and adds ASIO compile definitions. Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: 🟡 Moderate · up to The PR changes ASIO device selection, persistence, and Windows CI behavior. At the current head, duplex audio can bypass sample-rate validation and undefined matrix references can break build execution; device restoration and build-input handling also have bounded correctness and security risks. Merge should wait for these concrete issues to be fixed or explicitly accepted. Sequence Diagram(s)sequenceDiagram
participant DevicePrefs
participant DeviceManager
participant ASIO_Driver as ASIO driver
participant AudioIO_Start as AudioIO::GetBestRate
DevicePrefs->>DeviceManager: refresh selected ASIO capabilities
DevicePrefs->>ASIO_Driver: open control panel
ASIO_Driver-->>DeviceManager: update rate and channel data
DeviceManager-->>DevicePrefs: return updated capabilities
AudioIO_Start->>DeviceManager: query current ASIO sample rate
DeviceManager-->>AudioIO_Start: return selected device rate
🚥 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 |
46d5128 to
60752db
Compare
| // pick a rate to do the audio I/O at, from those available. The project | ||
| // rate is suggested, but we may get something else if it isn't supported | ||
| mRate = GetBestRate(numCaptureChannels > 0, numPlaybackChannels > 0, sampleRate); | ||
| mRate = 0.0; | ||
|
|
||
| // Opening ASIO streams at the device's current rate allows simultaneous | ||
| // playback with drivers that support it. | ||
| if (AudioIOUseAsioDeviceSampleRate.Read()) { | ||
| const int asioDevIndex = numPlaybackChannels > 0 ? | ||
| getPlayDevIndex() : getRecordDevIndex(); | ||
| if (DeviceManager::IsAsioDevice(asioDevIndex)) | ||
| mRate = DeviceManager::GetAsioDeviceCurrentSampleRate(asioDevIndex); | ||
| } | ||
|
|
||
| if (mRate == 0.0) | ||
| mRate = GetBestRate( | ||
| numCaptureChannels > 0, numPlaybackChannels > 0, sampleRate); | ||
|
|
||
| // GetBestRate() will return 0.0 for bidirectional streams when there is no |
There was a problem hiding this comment.
maybe this logic should be part of GetBestRate because we use also the best rate here:
AudioIOStartStreamOptions
DefaultSpeedPlayOptions( AudacityProject &project )
{
auto result = ProjectAudioIO::GetDefaultOptions( project );
auto gAudioIO = AudioIO::Get();
auto PlayAtSpeedRate = gAudioIO->GetBestRate(
false, //not capturing
true, //is playing
ProjectRate::Get( project ).GetRate() //suggested rate
);
result.rate = PlayAtSpeedRate;
return result;
}so we avoid duplicating that ASIO specific thing right?
| auto audioIO = AudioIOBase::Get(); | ||
| if (audioIO && audioIO->IsBusy()) { | ||
| if (!audioIO->IsMonitoring()) | ||
| return; | ||
|
|
||
| audioIO->StopStream(); | ||
| while (audioIO->IsBusy()) { | ||
| using namespace std::chrono; | ||
| std::this_thread::sleep_for(100ms); | ||
| } | ||
| } |
There was a problem hiding this comment.
IsBusy() means mStreamToken != 0, IsMonitoring() requires mStreamToken == 0
so we would never stop monitoring stream right? and allow opening the panel, maybe we should do something like this right?
auto audioIO = AudioIOBase::Get();
if (audioIO) {
if (audioIO->IsBusy())
return;
if (audioIO->IsMonitoring()) {
audioIO->StopStream();
while (audioIO->IsMonitoring()) {
using namespace std::chrono;
std::this_thread::sleep_for(100ms);
}
}
}
DeviceManager::ShowAsioControlPanel(deviceIndex);There was a problem hiding this comment.
thanks, thats much better! Also, I think there is no need for polling, StopStream already waits in WaitForAudioThreadStopped
60752db to
d69019b
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/toolbars/AudioSetupToolBar.cpp (1)
261-268: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRestore remembered host devices before global device preferences.
When a device string exists on both hosts, each toolbar selects the previous global preference first. The remembered-device branch does not run. This defeats host-specific restoration for common device names.
src/toolbars/AudioSetupToolBar.cpp#L261-L268: selectrememberedInbefore attemptingmInput.Set(desc).src/toolbars/AudioSetupToolBar.cpp#L297-L301: selectrememberedOutbefore attemptingmOutput.Set(desc).src/toolbars/DeviceToolBar.cpp#L276-L282: selectrememberedInbefore testingdesc.src/toolbars/DeviceToolBar.cpp#L309-L314: selectrememberedOutbefore testingdesc..github/workflows/build.yml (1)
192-194: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRemove undefined
matrix.config.force_gcc11references.Keep this input only in
build_linux. Remove it frombuild_windows,build_macos_intel,build_macos_arm64, andsources. These jobs do not define the referenced property or matrix context, which causesactionlinterrors.Source: Linters/SAST tools
🧹 Nitpick comments (1)
.github/workflows/build.yml (1)
214-214: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winValidate
BUILD_TYPEbefore PowerShell interpolation.
workflow_dispatch.build_typeandworkflow_call.build_typeare unrestricted string inputs. GitHub expands${{ env.BUILD_TYPE }}before PowerShell parses the script, so PowerShell syntax in the input can add commands. Validate the value against the documented build types and use$env:BUILD_TYPE.Source: Linters/SAST tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: ed7949ce-a23a-4265-83f3-e8c2380da815
📥 Commits
Reviewing files that changed from the base of the PR and between 60752dbd8d321f2471b49062d07551a7a5018689 and d69019b94b2ec01772a95a02b7f400774337abdf.
📒 Files selected for processing (8)
.github/workflows/build.ymlconan/conanfile.pylibraries/lib-audio-devices/DeviceManager.cpplibraries/lib-audio-devices/DeviceManager.hlibraries/lib-audio-io/AudioIO.cppsrc/prefs/DevicePrefs.cppsrc/toolbars/AudioSetupToolBar.cppsrc/toolbars/DeviceToolBar.cpp
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.
|
Issue with retaining devices when switching hosts is fixed, thanks! |
d69019b to
3ec6d98
Compare
Resolves: adds asio in windows build
Recommended:
QA: