With rust-jack 0.7, the buffer_size callback is moved to
ProcessHandler. This reflects how it is actually called by jack:
it is called synchronously on the process thread, but it is allowed to
perform non-real-time-safe operations. In CPAL, this means that
it is fine to reallocate the temporary interlacing buffers when buffer
size changes.
This removes the need for buffer splitting on the output stream type,
and prevents panics when buffer size is made larger than initially on
the input stream type. (for some reason, buffer splitting was not
implemented for input previously)
This was introduced in 6b91485 and could cause issues with some alsa
configurations like that of pipewire-alsa which caused the audio to be
become weirdly distorted
To compensate for the removal of `failure`'s application friendly
`failure::Error` trait, this `anyhow` crate has been added as a
dev-dependency for the examples, but is by no means a necessity for
other crates downstream of CPAL.
Currently CPAL only really uses `failure` for its `derive` capabilities
and the ability to easily generate implementations for `Display`. That
said there are a few issues with using the `failure` crate:
- `failure` does not provie a `std::error::Error` implementation without
first converting error types into `failure::Error`.
- It leaks significantly into the public API and expects downstream
users to also depend on `failure` and the non-std `Fail` trait for
their own error handling.
- Solved problems such as downcasting of causal errors which have since
been addressed in `std`.
- Provides application-friendly `Fail` trait and `failure::Error` type,
not particularly useful to libraries like CPAL.
The [`thiserror` crate](https://github.com/dtolnay/thiserror) is better
targeted towards libraries, does not leak into the public API while
providing easy generation of `Display`, `From` and `std::error::Error`
implementations including proper handling of the newish
`std::error::Error::source` method.
When using cpal as dependency in other project, it was found that cpal
won't build due to unresolved import of winapi::um::winbase. Added the
feature at line 24 in Cargo.toml.
This is quite a significant update for CPAL, including a number of
breaking changes. Here is a list of the breaking changes along with
links to where you can find more information:
- A `Host` API has been introduced in #289 along with a follow-up
refactor in #295. Please see the examples for a demonstration of how
to update your code. The necessary changes should hopefully be
minimal. If this has caused you any major difficulty please let us
know in an issue!
- An ASIO host has been introduced in #292. This adds support for
Steinberg's ASIO audio driver API on Windows. Please see the ASIO
section of the README for more information on how to setup CPAL with
ASIO support for your project.
- The user callback API has been overhauled to emit `StreamEvent`s
rather than buffers in order to support handling stream errors. #288.
- Error handling in general was overhauled in #286. This meant taking
advantage of the `failure` crate and adding support for
backend-specific errors with custom messages. Many unnecessary
`panic!`s have been removed, but a few remain that would indicate bugs
in CPAL.
In general, checking out the updated examples will be the easiest way to
get a quick overview on how you can update your own code for these
changes.
The CHANGELOG.md has been updated to include these changes.