Skip to content

ASIO: collecting output_devices() into Vec only returns the first device #1106

Description

@mikai233

Summary

On Windows ASIO, host.output_devices() behaves differently depending on whether the iterator is collected first.

  • Iterating directly prints all devices.
  • Collecting into Vec<_> first, then iterating, only prints the first device.

collect should not change the visible device set.

Environment

  • cpal: 0.17.1
  • OS: Windows (x64)
  • Backend: ASIO (cpal::HostId::Asio)
  • Devices in my setup:
    • Focusrite USB ASIO
    • Realtek ASIO
    • USB DAC ASIO

Minimal Repro

use anyhow::Result;
use cpal::traits::{DeviceTrait, HostTrait};

fn list_output_devices() -> Result<()> {
    let host = cpal::host_from_id(cpal::HostId::Asio)?;
    let devices = host.output_devices()?;
    // let devices = devices.collect::<Vec<_>>();
    for device in devices {
        println!("{}", device.description()?);
    }
    Ok(())
}

fn main() -> Result<()> {
    list_output_devices()
}

Actual Behavior

Without collect:

Focusrite USB ASIO
Realtek ASIO
USB DAC ASIO

With:

let devices = devices.collect::<Vec<_>>();

Only the first device is printed:

Focusrite USB ASIO

Expected Behavior

Both versions should enumerate the same set of devices (all 3 in this environment).

Related

Possibly related to ASIO enumeration/lifetime behavior in #798 (this repro is single-threaded and triggered by collecting Device values).

Activity

  1. roderickvd commented on Feb 18, 2026

    @roderickvd
    Member

    Thanks for the report. This is due to ASIO only allowing one driver being loaded at a time. Please try out #1107.

  2. roderickvd commented on Feb 23, 2026

    @roderickvd
    Member

    @mikai233 sorry, I went ahead merging #1107 because I mistakenly thought that you had already confirmed it works. Let me know if it does or doesn't.

  3. mikai233 commented on Feb 24, 2026

    @mikai233
    Author

    Hi @roderickvd — sorry for the late reply. I’ve been busy with my project and didn’t get a chance to follow up in time.

    I retested on the latest master after the fix was merged:

    cpal v0.18.0 (https://github.com/RustAudio/cpal.git#1c64e49c) (from cargo tree -i cpal)

    Windows + ASIO

    On my side, the enumeration is still missing one device, and now it happens both when iterating directly and when collecting into a Vec first (so the behavior is consistent, but still incomplete).

    Current output:

    Focusrite USB ASIO
    USB DAC ASIO
    
  4. added a commit that references this issue on Feb 24, 2026
    dcfce39
  5. roderickvd commented on Feb 24, 2026

    @roderickvd
    Member

    No worries, thanks for the feedback. Please try #1112.
    (I don't have ASIO so I am doing this purely from a code standpoint, please bear with me.)

  6. mikai233 commented on Feb 25, 2026

    @mikai233
    Author

    @roderickvd, I've tested the new fix and confirmed it works well both when iterating and when collecting into a Vec on the minimal reproducible example. I've also tested it in my music player, and it works perfectly there too. Thanks for the fix!

  7. added a commit that references this issue on Feb 26, 2026
    11f7726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions