Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples don't work on Windows with ASIO #133

Open
Boscop opened this issue Apr 13, 2016 · 7 comments
Open

Examples don't work on Windows with ASIO #133

Boscop opened this issue Apr 13, 2016 · 7 comments

Comments

@Boscop
Copy link
Member

Boscop commented Apr 13, 2016

I built portaudio from the latest SVN snapshot with ASIO support (no other API) and debugging enabled for win32.
(I have an ASIO compatible audio interface (Steinberg UR22) that works with ASIO usually, which portaudio correctly identifies as the default device.)
Then tried to run the examples (also win32), but they don't work as they should.
What they have in common is this output from portaudio:

PinNew: Error -9999
...
FilterNew: Error -9985
...
Filter NOT created

So for some reason it can't open the audio interface.
The blocking example crashes sometimes (sometimes not), the others run but there is no sound coming out.
Maybe the issue is with the access to the audio interface?
I noticed that some DAWs that support ASIO as a backend will give up if the audio interface is already in use, and others will "steal" the access from the existing owner. How can I force portaudio to steal the access? (Even though in this case I think the audio interface shouldn't have been in use.)

See debug output in the attachments:
blocking.txt
devices.txt
non_blocking.txt
saw.txt
sine.txt

I tried to debug the examples using Visual Studio but it only shows asm, not very helpful:
blocking
The point of failure is apparently in wdmaud.drv. But my audio interface works with ASIO in other Software like Reaper, Ableton etc. so somehow portaudio must be causing it..
When I run blocking outside of Visual Studio:

Maybe portaudio is trying to open the device using the wrong parameters?

@mitchmindtree
Copy link
Member

I came across this guide for building portaudio for windows (with some specifics for ASIO use) - not sure if it helps?

It seems strange that processes would give up on accessing ASIO if already in use - shouldn't it be ASIOs job to manage signals from multiple processes (or at least invoke the OS to do so)? I.e. Reaper and Ableton should be able to play back simultaneously right?

@mitchmindtree
Copy link
Member

Maybe portaudio is trying to open the device using the wrong parameters?

So I'm just having a closer look at the devices.rs example output now. Interestingly, the UR22mkII seems to be split across multiple devices:

--------------------------------------- DeviceIndex(1)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 0,
    max_input_channels: 2,
    max_output_channels: 0,
    default_low_input_latency: 0.09,
    default_low_output_latency: 0.09,
    default_high_input_latency: 0.18,
    default_high_output_latency: 0.18,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for half-duplex 16-bit 0 channel output:
Supported standard sample rates for full-duplex 16-bit 2 channel input, 0 channel output:
--------------------------------------- DeviceIndex(10)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 0,
    max_input_channels: 0,
    max_output_channels: 2,
    default_low_input_latency: 0.09,
    default_low_output_latency: 0.09,
    default_high_input_latency: 0.18,
    default_high_output_latency: 0.18,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 0 channel input:
Supported standard sample rates for half-duplex 16-bit 2 channel output:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:
--------------------------------------- DeviceIndex(20)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 1,
    max_input_channels: 0,
    max_output_channels: 2,
    default_low_input_latency: 0,
    default_low_output_latency: 0.003,
    default_high_input_latency: 0,
    default_high_output_latency: 0.01,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 0 channel input:
Supported standard sample rates for half-duplex 16-bit 2 channel output:
    44100hz
Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:
--------------------------------------- DeviceIndex(32)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 1,
    max_input_channels: 2,
    max_output_channels: 0,
    default_low_input_latency: 0.003,
    default_low_output_latency: 0,
    default_high_input_latency: 0.01,
    default_high_output_latency: 0,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
    44100hz
Supported standard sample rates for half-duplex 16-bit 0 channel output:
Supported standard sample rates for full-duplex 16-bit 2 channel input, 0 channel output:
--------------------------------------- DeviceIndex(51)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII)",
    host_api: 2,
    max_input_channels: 2,
    max_output_channels: 0,
    default_low_input_latency: 0.01,
    default_low_output_latency: 0.01,
    default_high_input_latency: 0.08533333333333333,
    default_high_output_latency: 0.08533333333333333,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.325: Pin:cafa18, DataRange:0
 0.325:     FormatSize:88, SampleSize:0
 0.325:     MaxChannels:2
 0.325:     Bits:24-24
 0.325:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
    44100hz
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:cafa18, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
Supported standard sample rates for half-duplex 16-bit 0 channel output:
Supported standard sample rates for full-duplex 16-bit 2 channel input, 0 channel output:
--------------------------------------- DeviceIndex(52)
DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII)",
    host_api: 2,
    max_input_channels: 0,
    max_output_channels: 2,
    default_low_input_latency: 0.01,
    default_low_output_latency: 0.01,
    default_high_input_latency: 0.08533333333333333,
    default_high_output_latency: 0.08533333333333333,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 0 channel input:
Supported standard sample rates for half-duplex 16-bit 2 channel output:
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
    44100hz
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
 0.326: Pin:caeff8, DataRange:0
 0.326:     FormatSize:88, SampleSize:0
 0.326:     MaxChannels:2
 0.326:     Bits:24-24
 0.326:     SampleRate:44100-44100
Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:

@mitchmindtree
Copy link
Member

Note that none of the above are listed as duplex devices, i.e. each of them claim to only offer either input channels or output channels (not both).

Strangely, the last two devices (DeviceIndex(51) and 52) seem to output a bunch of device info to stdout when when queried for format compatibility.

@mitchmindtree
Copy link
Member

The non_blocking.rs example prints out the Host API as well as the default input and output device info.

PortAudio:
version: 1246464
version text: Ok("PortAudio V19.5.0-devel, revision 1968M")
host count: 3
default host: Some(
    HostApiInfo {
        struct_version: 1,
        host_type: MME,
        name: "MME",
        device_count: 18,
        default_input_device: Some(
            DeviceIndex(
                1
            )
        ),
        default_output_device: Some(
            DeviceIndex(
                10
            )
        )
    }
)
Default input device info: DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 0,
    max_input_channels: 2,
    max_output_channels: 0,
    default_low_input_latency: 0.09,
    default_low_output_latency: 0.09,
    default_high_input_latency: 0.18,
    default_high_output_latency: 0.18,
    default_sample_rate: 44100
}
Default output device info: DeviceInfo {
    struct_version: 2,
    name: "Line (Steinberg UR22mkII )",
    host_api: 0,
    max_input_channels: 0,
    max_output_channels: 2,
    default_low_input_latency: 0.09,
    default_low_output_latency: 0.09,
    default_high_input_latency: 0.18,
    default_high_output_latency: 0.18,
    default_sample_rate: 44100
}

It seems that the default devices used are DeviceIndex(1) for input and DeviceIndex(10) for output (the first two devices listed in the devices.rs in my previous comment). I thought that perhaps using separate devices in a duplex stream might be causing you issues, but now I think of it, I guess this shouldn't be the issue though as you're still getting issues with the saw.rs and sine.rs examples which are output-only streams.

Oh also, it looks like it is choosing MME as the default Host API... is this correct? Should this be ASIO instead? Perhaps it is worth listing the Host APIs, to see if the ASIO API needs to be manually selected? You should be able to do this using the HostApis iterator, something like this:

for (_idx, info) in pa.host_apis() {
    println!("{:#?}", info);
}

Edit: It looks like this might indeed be the case - see the bottom of this stackoverflow answer by Bencina himself (creator of PortAudio).

@mitchmindtree
Copy link
Member

I just added an example for displaying the default host API and enumerating all available host APIs.

@Boscop
Copy link
Member Author

Boscop commented Apr 17, 2016

Hey,

I found out what was wrong. Even though I had set PA_USE_ASIO=1 in the Preprocessor directives for "All Configurations", in the Debug and Release configurations it still had PA_USE_ASIO=0 as a preconfiguration, so in total it resulted in PA_USE_ASIO=1;[...];PA_USE_ASIO=0;[...] after auto-concatenation, so even though the asio source files were compiled in, it didn't use the code -.-

Anyway, so I corrected it and rebuilt the dll and changed the saw example to use ASIO specifically (required another struct, AsioStreamInfo, based on this), but it still doesn't work, it opens the audio interface but I still hear no saw wave! Why can this be?

This is the code and output:
saw_asio.rs
saw_asio output

@mitchmindtree
Copy link
Member

Related - #22 is the tracking issue for supporting the PortAudio extension headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants