Commit Graph

528 Commits

Author SHA1 Message Date
mitchmindtree b1539c534f Add handling of `Play`, `Pause` and `Close` stream events to emscripten 2019-06-22 17:47:31 +02:00
mitchmindtree b2c1226b47 Update coreaudio backend for `StreamEvent` API addition. 2019-06-22 17:14:42 +02:00
mitchmindtree fddea2edd8 Update the null and emscripten backends for StreamEvent API 2019-06-22 03:53:51 +02:00
mitchmindtree 3e3cf26cde Update `wasapi` backend for `StreamEvent` API addition.
Refactors much of the `EventLoop::run` implementation in order to make
error handling a little easier.
2019-06-22 03:47:05 +02:00
mitchmindtree 39cd5d0084 Update examples for addition of new StreamEvent API 2019-06-22 00:10:40 +02:00
mitchmindtree e41baa248b Update alsa backend for addition of `StreamEvent` type
This commit significantly refactors the alsa backend's `EventLoop::run`
implementation in order to allow for better error handling throughout
the loop. This removes many cases that would previously `panic!` in
favour of calling the user callback with the necessary error and
removing the corrupt stream. Seeing as the method cannot return, a
catch-all `panic!` still exists at the end of the method, however this
refactor should make it much easier to remove this restriction in the
future.
2019-06-22 00:06:55 +02:00
mitchmindtree 59c789fbcd Add new `StreamEvent` type - enables more flexible user callback API
This adds the following types:

- `StreamEvent`
- `CloseStreamCause`
- `StreamError`

These allow for notifying the user of the following events:

- A stream has been played.
- A stream has been paused.
- A stream has been closed due to user destroying stream.
- A stream has been closed due to an error.
2019-06-22 00:02:57 +02:00
mitchmindtree 9cc5df8805
Merge pull request #286 from mitchmindtree/error_handling
Error Handling Overhaul
2019-06-21 16:30:18 +02:00
mitchmindtree e2ec0eace2 Remove gnu target to avoid need to install gcc for cc crate 2019-06-21 16:17:58 +02:00
mitchmindtree d1a4f456de Remove 32-bit appveyor targets. Only build nightly on MSVC.
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.
2019-06-21 16:08:01 +02:00
mitchmindtree 2667547a9c Update lib docs to allow for testing on devices with no audio 2019-06-21 15:57:15 +02:00
mitchmindtree 61c3520d70 Try using a slightly more modern yml to address appveyor build bug
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.
2019-06-21 15:53:27 +02:00
mitchmindtree 6164f83147 Fix compiler errors in wasapi backend after testing on windows 2019-06-21 23:32:00 +10:00
mitchmindtree 0b6e66d38e Update examples to use std Termination 2019-06-21 14:55:21 +02:00
mitchmindtree a733bdb4f9 Fix compile errors on macOS 2019-06-21 03:11:20 +02:00
mitchmindtree eae0e18714 Add `PlayStreamError` and `PauseStreamError`.
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.
2019-06-21 03:04:15 +02:00
mitchmindtree ba8d354e93 Improve handling of `BuildStreamError` throughout crate. 2019-06-21 02:38:59 +02:00
mitchmindtree f0e4e312c1 Improve handling of the `DefaultFormatError` 2019-06-21 01:38:21 +02:00
mitchmindtree fbb97f51ef Update examples for DeviceNameError 2019-06-21 01:37:55 +02:00
mitchmindtree 105086a108 Add new `DeviceNameError` type
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.
2019-06-21 00:58:15 +02:00
mitchmindtree 78a7cb9e79 Change `SupportedFormatsError::Unknown` variant to `BackendSpecific`
This allows for also passing through a description of the
unknown/platform-specific error.
2019-06-21 00:55:27 +02:00
mitchmindtree 42fc702f53 Add `BackendSpecificError`. Add new `DevicesError`.
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.
2019-06-20 22:37:36 +02:00
mitchmindtree cf84ab906f Rename `CreationError` to `BuildStreamError`
For clarity and to tie the name more closesly to the methods within from
which it may be returned.
2019-06-20 21:31:15 +02:00
mitchmindtree 0f27c1e0bb Rename `FormatsEnumerationError` to `SupportedFormatsError`
This more tightly associates the error with the device method on which
this might occur.
2019-06-20 21:16:39 +02:00
mitchmindtree 1275db805b Remove std `Error` implementations in favour of using `failure`
This will make adding new errors in the following commits towards better
error handling a lot easier.
2019-06-20 21:12:17 +02:00
mitchmindtree 9c04bf7400
Merge pull request #285 from mohanson/patch-1
Update feedback.rs
2019-06-20 18:31:21 +02:00
Mohanson 6ceb3a215f
Update feedback.rs 2019-06-19 10:34:12 +08:00
mitchmindtree e6f61b3a82
Merge pull request #283 from ishitatsuyuki/no-mutex
Use channels instead of mutex
2019-06-13 13:03:38 +02:00
Tatsuyuki Ishi 1d3754fa7d Use channels instead of mutex 2019-06-13 15:31:37 +09:00
mitchmindtree 755eefedff
Merge pull request #280 from mitchmindtree/deref_panic
Remove unnecessary panic! from OutputBuffer Deref impl
2019-06-08 00:13:53 +02:00
mitchmindtree 960b1d5a40 Remove unnecessary panic! from OutputBuffer Deref impl
Since #269 this `panic!` is certainly unnecessary as `InputBuffer` and
`OutputBuffer` are a thin wrapper around a slice. That said, I'm
struggling to understand exactly why this `panic!` was necessary in the
first place.

This closes #228.
2019-06-07 21:05:14 +02:00
mitchmindtree d0cafd68bf
Merge pull request #276 from AustinJ235/master
Release 0.9.0
2019-06-07 15:39:52 +02:00
mitchmindtree 7f7e50c96a
Merge pull request #211 from mitchmindtree/feedback_example
Add an example that demonstrates feeding input directly to output with some latency
2019-06-06 18:09:09 +02:00
Austin Johnson 49b2c42443 add changelog entries for #248 #254 & #269; update version to 0.9.0 2019-06-06 10:29:52 -05:00
mitchmindtree 48e1a96e60
Merge pull request #244 from azyobuzin/WasapiBufferEmpty
Assertion failed in Windows
2019-06-06 15:24:24 +02:00
mitchmindtree ba4a29ae6c
Merge pull request #275 from desttinghim/invalid-params-fix
Don't panic when setting hardware params in alsa
2019-06-06 15:22:42 +02:00
Austin Johnson 78adc983f6 update hound & lazy_static; release 0.8.2 2019-06-06 00:49:49 -05:00
Louis Pearson e7c086d0af Return error from set_hw_params_from_format instead of crashing 2019-06-04 12:48:11 -06:00
mitchmindtree b82ca1e348
Merge pull request #235 from ArtemGr/master
Switching the headset on and off
2019-06-04 20:15:26 +02:00
mitchmindtree 72fd027f57
Merge pull request #269 from ishitatsuyuki/better-buffer
Better buffer handling
2019-06-04 19:51:45 +02:00
mitchmindtree 7861dd84da
Merge pull request #248 from RoflCopter24/master
Added error handling for unknown ALSA device errors
2019-05-30 23:56:43 +02:00
Tatsuyuki Ishi 4d3fe57fe3 Improved buffer management
- ALSA backend: reuse the buffers
- Make `InputBuffer` and `OutputBuffer` types just a wrapper of slice
  * Buffer is now submitted at the end of callback
2019-05-30 17:45:16 +09:00
mitchmindtree 0354548426
Merge pull request #267 from ishitatsuyuki/254-segfault
Fix #254, logic error in frame/sample size
2019-04-29 22:21:48 +10:00
Tatsuyuki Ishi af88cd87e2 Fix #254, logic error in frame/sample size 2019-04-29 20:33:03 +09:00
mitchmindtree 0b6df67085
Merge pull request #265 from simonrepp/master
Minor textual corrections in crate documentation intro
2019-04-23 03:09:10 +10:00
Simon Repp c2c7089d1a
Minor textual corrections in crate documentation intro 2019-04-22 13:55:42 +02:00
Chris Morgan 2679ea845f impl Debug for Device (#253)
The internal alsa, null and emscripten Device implementations already
implemented Debug; but the coreaudio and wasapi ones, and therefore
also the wrapper, did not.

I decided to eschew the `Device(…)` wrapping in the outer layer
(hence a custom implementation rather than `#[derive(Debug)]`),
because `Device(Device)`, `Device(Device { … })` and so forth all
look better without the extra `Device(…)` wrapping.

On the wasapi and coreaudio implementations I put both the pointer and
name. Name because it’s useful, pointer because on Windows at least
I believe duplicated names are possible. (e.g. two monitors that include
monitors, of the same type; I haven’t strictly confirmed this, because I
killed those off harshly on my machine and don’t want to reinstate
them.)

I do not have access to a macOS device to confirm that the coreaudio
implementation is sane, but I think it is.
2019-03-22 21:27:17 +01:00
Florian Vick 5cb45bfd7e
Added error handling for unknown ALSA device errors (#1)
Instead of taking the easy way out and killing the whole program by panicking, device enumeration and stream creation will now report the error variant 'Unknown'
2018-11-06 21:01:03 +01:00
azyobuzin 8a002b7077 Fix failing the assertion when HRESULT is AUDCLNT_S_BUFFER_EMPTY 2018-10-12 12:12:05 +09:00
Ben Boeckel c2d606176a readme: mention system dependencies (#240)
Fixes #229.
2018-09-17 15:57:51 +02:00