Repository navigation
Error Handling Overhaul - #286
Conversation
This will make adding new errors in the following commits towards better error handling a lot easier.
This more tightly associates the error with the device method on which this might occur.
For clarity and to tie the name more closesly to the methods within from which it may be returned.
See the documentation for both new errors for details. The new `DevicesError` has been added to allow for returning errors when enumerating devices. This has allowed to remove multiple potential `panic!`s in each of the alsa, coreaudio and wasapi backends.
This allows for also passing through a description of the unknown/platform-specific error.
6e944d3 to
78a7cb9
Compare
The coreaudio and wasapi backends may both potentially fail to produce the name associated with a device. This changes the API to allow for returning the errors in these cases.
This allows for properly handling potential failure on macOS. We should also consider propagating the mutex/channel poison errors through these new types, especially considering the potential removal of the event loop in favour of switching over to high-priority audio threads on windows and linux.
|
OK this should be just about ready to go, but I still want to test the examples on macOS and check that windows is compiling and running correctly (appveyor seems to be erroring out early on something unrelated). cc @ishitatsuyuki would you mind reviewing this if you get a chance in the meantime? It would be great to get your thoughts. |
|
Here are my thoughts after roughly looking through:
Regarding error types on play/pause methods: should we make it synchronous as described in the last line of #278 (comment)? Running the operations synchronously will allow us to return error (if it exists) on all platforms, making it more consistent. |
Ahh I see, I'm quite unfamiliar with appveyor, do you happen to know off the top of your head what needs to be added to our appveyor.yml to get this working again?
This sounds good to me! Do you still get the line number of the source of the error? I guess this error overhaul should make it clear where the error is coming from anyway. I'll give this a go!
Yeah I agree we should. I kind of had this in mind while making the new In the meantime I'm going to spin up a VM to test windows locally, and see if I can borrow a friend's MBP to test the coreaudio backend. |
Sorry no, I only looked at the error message and I have no experience with AppVeyor.
Yes, that was just a by-the-way proposal. Let's revisit after we redesign things around EventLoop. |
|
OK I've tested locally on both wasapi and coreaudio and can confirm everything compiles and that the examples all run as well as they did beforehand. I'm going to do some investigating into this appveyor issue now. |
|
Tip: you can check code by installing the |
This uses the script from here with all comments stripped: https://github.com/starkat99/appveyor-rust/ The beta targets have also been removed to keep build times low.
As appveyor only does one job at a time, this should help to keep appveyor builds under 5 minutes... Otherwise we're looking at 15+ min build times.
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 RustAudio#289 along with a follow-up refactor in RustAudio#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 RustAudio#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. RustAudio#288. - Error handling in general was overhauled in RustAudio#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.
The aim of this PR is to overhaul the way that errors are handled throughout the crate as discussed within #268.
I will continue to update the following list and commit to this PR as I make progress. Feel free to comment at any stage!
TODO:
failurecrate to make error implementation and propagation more ergonomic.panic!s and improve error handling where necessary, which may include adding new error types or new variants to existing error types.Follow-up PR:
Eventenum as described here.