weixin_39587822
weixin_39587822
2020-11-23 04:08

Asio Backend Support

Support for ASIO backend on windows

Current state

This is a very early stage attempt. There's lots to do before merging. I just want to start getting some feedback.

Feedback: I'm fairly new to Rust so there's definitely going to be mistakes / non-idiomatic code in here. Feel free to point out anything you think is weird / wrong or ask for explanations.

Things that are working: - The enumerate example - The beep example - Building the ASIO library and linking to it - Creating the bindings to the library with bindgen

Things that still need to be done (non-exhaustive): - [x] The record_wav example - [ ] Supporting all the possible ASIO formats - [x] Allow the CPAL user to set if the want ASIO or WASAPI at with an initialize call - [x] Check for potential threading issue (I'm new to this) - [ ] Stop any panics that could cross FFI boundaries - [x] Add comments and example usage docs - [x] Make the interleaving faster and avoid copying

Usage

  1. You need to download the ASIO SDK and unzip it somewhere.
  2. Put the full path into the environment variable CPAL_ASIO_DIR eg. with powershell ($env:CPAL_ASIO_DIR="C:\Users\you\my_libs\ASIOSDK2.3")
  3. Now you should be able to run "cargo run --example enumerate" Note: The beep example is currently hard set to select ASIO 4 All because there's no way to get the default asio driver and this made testing easier.

Resources

  • This is a good write up about how portaudio built there asio backend.
  • Theres a pdf in the ASIO sdk called ASIO SDK 2.3.pdf that explains the how ASIO works
  • Theres an example of how to write an ASIO host in c++ in ASIOSDK2.3/host/sample/hostsample.cpp

Note: I had to change branches and make this pr because of conflict problems.

该提问来源于开源项目:RustAudio/cpal

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39587822 weixin_39587822 4月前

    I noticed that this isn't passing tests on Android because of this:

    130 | use null as platform; | ---------------- previous import of the module platform here ... 141 | mod platform; | ^^^^^^^^^^^^^ platform redefined here

    Might need to change the name of the platform module?

    点赞 评论 复制链接分享
  • weixin_39587822 weixin_39587822 4月前

    So it doesn't appear that ASIO4All is passing on the correct bit rate when the actual device is changed. It does detect a the correct rate when a different asio driver (for example dante) is running. This might be a bug with ASIO4All but seeing as that is the most popular choice for people using asio we might need to investigate this further.

    点赞 评论 复制链接分享
  • weixin_39834406 weixin_39834406 4月前

    :warning: Note for those testing this PR :warning:

    Make sure you first read and follow the the step-by-step setup for using ASIO on Windows in the updated README. Hopefully we can automate more of this process in the future.

    点赞 评论 复制链接分享
  • weixin_39834406 weixin_39834406 4月前

    Just leaving a note here that my current intention is to assist in addressing #268 and #204 first, then I'll look into rebasing this on top of that work.

    点赞 评论 复制链接分享
  • weixin_39587822 weixin_39587822 4月前

    What are your thoughts on using the sample crate to handle conversions between types? This is the current state of affairs and it's incomplete / probably wrong.

    点赞 评论 复制链接分享