ruuda / hound

A wav encoding and decoding library in Rust

Home Page:https://codeberg.org/ruuda/hound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cpal.rs example does not build using cargo test

zyvitski opened this issue · comments

I've never used the cpal library but it seems that the version of cpal that hound is currently tied to is quite out of date. The cargo.toml specifies v0.1.2 where the latest version is v0.4.0. When trying to build and run the test target for hound compilation failed due to the dependency on cpal failing to build.

I believe the cpal example either needs to be removed or updated to work with the current version of cpal.

I would be glad to update the example, but I would like to verify that the issue is not just local to my system. The error message:

cargo test
   Compiling cpal v0.1.2
error[E0463]: can't find crate for `coreaudio`
 --> /Users/alexanderzywicki/.cargo/registry/src/github.com-1ecc6299db9ec823/cpal-0.1.2/src/coreaudio/mod.rs:1:1
  |
1 | extern crate coreaudio_rs as coreaudio;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

error: Could not compile `cpal`.

I am running on OSX 10.12.3

Yes, the example is using a very old version of cpal. After that, cpal had some quite invasive changes that make it a lot harder to quickly get some audio output. (The trade off is that the new version it is more configurable and it has better error handling.) I looked into updating a while ago, but it did not seem worth the effort as long as the old version was still working fine.

The example still compiles for me with the following Cargo.lock. Does that work for you?

[root]
name = "hound"
version = "3.0.1"
dependencies = [
 "cpal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "alsa-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
 "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "bitflags"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "coreaudio-rs"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "coreaudio-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "coreaudio-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "cpal"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "alsa-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "coreaudio-rs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
 "ole32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "libc"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "ole32-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "pkg-config"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"

[metadata]
"checksum alsa-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9013f855a808ab924a4c08b5c1ec9bd6b04fdb2295b4d570fb723e0ed2802a4f"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum coreaudio-rs 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a633fa29946681f8c98ad593c00a84189961970a01e317b054cdd7628794f7f"
"checksum coreaudio-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31231897622a4cd14cb211af6f26d6fcf0c78078fa60c586ce9db8f0b581cd44"
"checksum cpal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "14054bb3482bf7098648b4ef46afc560f74ba512cb025b54ce834cda6b4a8a73"
"checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135"
"checksum ole32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9408b8ab87fd713ba77e4ac1f947107ae00593b08da309cfcf1c82bb7b1ecf0"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"

It does not. I think it would probably be a good idea to put that example behind a feature gate, or update/remove it.

In that case we should update the example. It seems that cpal is still the best cross-platform option for quickly getting some audio output.

If you like to update it, go ahead. Otherwise I’ll look into it myself soon.

I would usually suggest switch to portaudio-rs but it depends on having the portaudio lib already installed on your machine. I will look into updating the cpal example. I have not used cpal before but I am very familiar with audio programming so it should be no issue to update the example.

Can you describe the behavior of the previous example, since I cannot build it I would like to make sure that I am updating the example to be behaviorally equivalent.

It simply plays back a wav file on the default audio device — read the samples and feed them into cpal.

I think I may do some research into which library is currently the best for audio in rust. From what I can tell CPAL has been having quite a few issues lately and it may not be wise to update the example just yet. I think it may be a good idea to just set the example up as ignored like the sound_stream one. The reason i am suggesting this is because the issues with the cpal example were stopping me from being able to run the unit tests while working on the float write enhancements

It does compile on Travis still. What platform are you using?

Oh, OS X, you mentioned. And the coreaudio dependency is broken there for some reason. We could exclude the example on OS X with a cfg rule, but that functionality is relatively new in Cargo ... Just upgrading it might be the best way to go.

No matter which option we choose I think it would be a good idea to somehow make it so that the examples don't get compiled along with the tests. That was the main issue. I couldn't run the tests because the example was failing to build. It made it harder to work on the library and write the tests for the changes I was making because I had to go in an disable the example

Cargo compiles the examples in examples when you run cargo test, this is by design. It is to ensure that the examples stay up to date. Without that we wouldn’t have caught the failure in the first place. I’ll try to update it and to add CI for OS X too.

I’ve updated the example and added an OS X target to the CI configuration. Indeed the example did not compile on OS X before, but now it does. Could you please verify that it works on your machine now?

Just tested it out and it is working!

Fixed by 5a75655 then.