Skip to content

Add ASIO support [audacity3] - #11690

Merged
kryksyh merged 3 commits into
audacity:audacity3from
kryksyh:asio_support_au3
Aug 18, 2026
Merged

kryksyh merged 3 commits into
audacity:audacity3from
kryksyh:asio_support_au3

Conversation

@kryksyh

@kryksyh kryksyh commented Aug 14, 2026

Copy link
Copy Markdown
Member

Resolves: adds asio in windows build

  • 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:

  • Testflow test cases have been run

@kryksyh kryksyh changed the title Add ASIO support Add ASIO support [audacity3] Aug 14, 2026
@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change enables Windows ASIO support by default and adds ASIO compile definitions. DeviceManager detects ASIO devices, caches and updates capabilities, queries current sample rates, opens the driver panel, and stores devices per host. Audio startup can use the selected ASIO device rate. Device preferences and toolbars add ASIO controls and restore devices per host. Build documentation no longer labels ASIO as experimental.

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

Merge Risk: 🟡 Moderate · up to d6901

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
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding ASIO support, with an optional branch identifier.
Description check ✅ Passed The description includes the required sections and completed checklist items; the summary is brief and QA testing remains unchecked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@kryksyh
kryksyh force-pushed the asio_support_au3 branch 2 times, most recently from 46d5128 to 60752db Compare August 14, 2026 17:42
@kryksyh
kryksyh requested a review from luapmartin August 14, 2026 18:31
@kryksyh kryksyh moved this from To-Do to Ready for QA in [AU3] Main board Aug 14, 2026
@kryksyh kryksyh added this to the Audacity 3.7.9 milestone Aug 14, 2026
Comment on lines 494 to 511
// 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@chinakov chinakov moved this from Ready for QA to In Progress in [AU3] Main board Aug 17, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Ready for QA in [AU3] Main board Aug 17, 2026
Comment thread src/prefs/DevicePrefs.cpp
Comment on lines +553 to +563
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);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks, thats much better! Also, I think there is no need for polling, StopStream already waits in WaitForAudioThreadStopped

@ianalarina ianalarina moved this from Ready for QA to In QA in [AU3] Main board Aug 17, 2026

@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: 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 win

Restore 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: select rememberedIn before attempting mInput.Set(desc).
  • src/toolbars/AudioSetupToolBar.cpp#L297-L301: select rememberedOut before attempting mOutput.Set(desc).
  • src/toolbars/DeviceToolBar.cpp#L276-L282: select rememberedIn before testing desc.
  • src/toolbars/DeviceToolBar.cpp#L309-L314: select rememberedOut before testing desc.
.github/workflows/build.yml (1)

192-194: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove undefined matrix.config.force_gcc11 references.

Keep this input only in build_linux. Remove it from build_windows, build_macos_intel, build_macos_arm64, and sources. These jobs do not define the referenced property or matrix context, which causes actionlint errors.

Source: Linters/SAST tools

🧹 Nitpick comments (1)
.github/workflows/build.yml (1)

214-214: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Validate BUILD_TYPE before PowerShell interpolation.

workflow_dispatch.build_type and workflow_call.build_type are 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.yml
  • conan/conanfile.py
  • libraries/lib-audio-devices/DeviceManager.cpp
  • libraries/lib-audio-devices/DeviceManager.h
  • libraries/lib-audio-io/AudioIO.cpp
  • src/prefs/DevicePrefs.cpp
  • src/toolbars/AudioSetupToolBar.cpp
  • src/toolbars/DeviceToolBar.cpp

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.

Comment thread libraries/lib-audio-io/AudioIO.cpp Resolved
Comment thread src/prefs/DevicePrefs.cpp Resolved
@chinakov chinakov moved this from In QA to Ready for merge in [AU3] Main board Aug 18, 2026
@chinakov

Copy link
Copy Markdown
Contributor

Issue with retaining devices when switching hosts is fixed, thanks!

@kryksyh
kryksyh merged commit 691f228 into audacity:audacity3 Aug 18, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for merge to Done in [AU3] Main board Aug 18, 2026
@kryksyh
kryksyh deleted the asio_support_au3 branch August 18, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants