Commit graph

160 commits

Author SHA1 Message Date
Adrien Prokopowicz
459499686e
Remove thiserror and replace it with hand written Error impls 2023-02-25 20:41:07 +01:00
alichay
7e17373e31
Add rustdoc links in most of the documentation (#682)
* Add rustdoc links in most of the documentation

Additionally, fix a couple of references to old
renamed types still lingering in the docs :)

Fixes #650

* Rustfmt on documentation changes

* Make docs for impl_platform_host not build example
2022-11-04 21:57:23 +01:00
Caden Haustein
29999e6857
Remove stdweb in favor of js-sys, web-sys, and wasm-bindgen (#713) 2022-10-25 03:46:28 +02:00
mbodmer
0a3e8c2208
add timeout paramter to DeviceTrait stream builders (#696)
* add timeout paramter to DeviceTrait stream builders

This makes it possible for the library client to handle situations where the host
takes too long to respond or even blocks forever, eg. a retry can be applied.

if the timeout passed is "None" the current behaviour is applied, eg. blocking forever.
if the timeout passed is a Duration then it will be applied to the Device Streams.
This is only implemented for ALSA, the other hosts will ignore the parameter for now.

Signed-off-by: Marc Bodmer <marc.bodmer@securiton.ch>
2022-10-18 18:15:31 +02:00
Kai Giebeler
85d773d59f Migrate Sample to dasp_sample (#689) 2022-10-07 14:08:54 +02:00
Kai Giebeler
e78a847272 fix some clippy warnings 2022-09-20 21:51:20 +02:00
yamadapc
493a0904f3 Also export constructor for SupportedStreamConfig
This is related to #535.
2022-07-06 22:11:23 +02:00
yamadapc
411c671c33 Add constructor for SupportedStreamConfigRange
This is related to #535.
2022-07-06 22:11:23 +02:00
James Liu
223f28262a
Update dependencies, switch to once_cell (#673) 2022-06-06 02:18:23 +02:00
Rémi Lauzier
ba462dad18
Fix some typo and warnings 2021-06-29 11:30:26 -04:00
mitchmindtree
81a7414d0b
Merge pull request #464 from ely-uf/chore/docs-fix-stream-link
Fix broken Stream concept link in the docs.
2020-10-27 23:37:24 +01:00
mitchmindtree
c3fce0bc7b
Merge pull request #452 from darakshan/master
Eliminate or suppress Clippy messages.
2020-10-27 23:36:28 +01:00
nicoo
ec818828f5
SampleRate: Implement std::ops::{Div, Mul}
Closes #482
2020-10-04 15:07:49 +02:00
ely-uf
e092dcc7a6 Fix broken Stream concept link in the docs.
Affects the "How to use cpal" section on the main page of the docs.

Point the `Stream` link to the `struct Stream` following the example
of the `Device` and `Host` links from the same section.
2020-08-02 18:58:26 +03:00
AlexanderHarrison
104f04c9a1
Fix issue #461 2020-07-29 17:43:17 -06:00
Darakshan Farber
7d35b7d448 rustfmt 2020-07-21 17:59:53 -07:00
Darakshan Farber
17e079d15d Eliminate or suppress Clippy messages. 2020-07-21 12:54:49 -07:00
Rob Watson
c8fc1002cb Add test for cmp_default_heuristics 2020-07-14 22:05:55 +02:00
JoshuaBatty
4ce12a69b9 adds docs for BufferSize and fixes buffersize bugs in emscripten and alsa 2020-07-14 13:19:26 +02:00
JoshuaBatty
7c1adce330 adds support for buffersizes in webaudio and emscripten 2020-05-27 12:05:55 +02:00
JoshuaBatty
935fa280d3 buffersizes api for wasapi 2020-05-26 14:55:55 +02:00
JoshuaBatty
9e660da433 implemented buffersizes for asio 2020-05-26 14:55:55 +02:00
JoshuaBatty
d72b546dca gets buffersize range and allows to set buffersize for alsa 2020-05-26 14:55:55 +02:00
JoshuaBatty
7eb45bca6f cargo fmt 2020-05-26 14:55:55 +02:00
JoshuaBatty
919722a785 with_sample_rate_and_buffer_size sample_rate is set to self.max_sample_rate 2020-05-26 14:55:55 +02:00
JoshuaBatty
f762e5dd8f prototyping an API for getting min and max buffersize 2020-05-26 14:55:55 +02:00
mitchmindtree
78e1796ba8 Add callback and playback timestamp implementation for webaudio stream 2020-05-22 14:35:29 +02:00
mitchmindtree
981507391a Add a table describing the source of StreamTimestamp for each host 2020-04-30 14:08:00 +02:00
mitchmindtree
777a6b2bd1 Change StreamInstant to use a signed representation
Using an unsigned representation was problematic as some platforms
provide no exact "capture" instant. As a result, we need to calculate
the instant of capture by subtracting the buffer duration from the
callback duration. In some cases this would occasionally cause the
unsigned representation to underflow unnecessarily.
2020-04-28 17:37:48 +02:00
mitchmindtree
4cb50663d8 WIP Begin work on the timestamp and StreamInstant APIs 2020-04-27 18:14:29 +02:00
mitchmindtree
bcf962c447 Add a CallbackInfo argument to the stream data callback
I began on an implementation of the timestamp API described in #363 but
quickly realised that it might be best to land the API for providing
extra information to the user's callback first.

This PR adds two new types: `InputCallbackInfo` and `OutputCallbackInfo`.
These types are delivered to the user's data callback as a new, second
argument.

While these types are currently empty, the intention is for these types
to provide information relevant to the current request for or delivery
of data. This includes:

- Timestamp information #363.
- Flags related to the state of the stream (e.g buffer
  underflow/overflow).

In order to maintain flexibility to avoid breaking things, I figure we
can keep the fields of these types private and provide methods for
retrieving this info.

@Ralith, @ishitatsuyuki does this seem OK to you?
2020-04-16 14:50:36 +02:00
Dan
bf276e7de6 fix sample rate range assertion 2020-03-17 23:16:04 -04:00
mitchmindtree
7a6cb0bd6a Make SupportedStreamConfigRange fields private 2020-02-02 20:20:51 +01:00
mitchmindtree
476f6c4c2c Only allow for private construction of SupportedStreamConfig.
This should give the user a higher confidence that, if they have a
`SupportedStreamConfig` format type that it is actually supported.

Also updates the `raw` stream builder methods to take a `StreamConfig`
and `SampleFormat` as separate arguments for flexibility.

**Backends Updated**

- [x] null
- [x] alsa
- [ ] emscripten
- [ ] coreaudio
- [ ] wasapi
- [ ] asio
2020-02-02 18:43:30 +01:00
mitchmindtree
9c781bd381 Rename stream Format types to Config
This implements the changes described at #370.

This commit implements only the `null` and `alsa` backends - the rest
will be implemented in follow-up commits.

Closes #370.
2020-01-27 21:28:07 +01:00
Benjamin Saunders
076b814a15 Introduce polymorphic stream constructors 2020-01-21 22:20:26 -08:00
Benjamin Saunders
78df791377 Add _raw suffix to stream constructors 2020-01-21 21:52:18 -08:00
mitchmindtree
aab0d90add Remove old .rustfmt.toml config. Run default cargo fmt on repo.
Seeing as a few large refactors have landed recently, I thought I'd take
this opportunity to do a `cargo fmt` run and standardise on the default
rustfmt settings.
2020-01-20 20:35:23 +01:00
mitchmindtree
dbb1cc4140 Add some notes for devs about the safety requirements of Data 2020-01-19 19:05:17 +01:00
mitchmindtree
3fdf189848 Update docs for addition of the new stream Data type 2020-01-19 16:16:09 +01:00
mitchmindtree
58356f49b4 An alternative approach to removing UnknownBufferType.
This is a potential alternative to #359. This PR is based on #359.

This approach opts for a dynamically checked sample type approach with
the aim of minimising compile time and binary size.

You can read more discussion on this [here](https://github.com/RustAudio/cpal/pull/359#issuecomment-575931461)

Implemented backends:

- [x] null
- [x] ALSA
- [ ] CoreAudio
- [ ] WASAPI
- [ ] ASIO
- [ ] Emscripten
2020-01-19 15:06:19 +01:00
mitchmindtree
5a619877f9 Update docs for removal of UnknownTypeBuffer 2020-01-18 15:13:17 +01:00
mitchmindtree
05b62bb1c0 Remove UnknownTypeBuffer in favour of specifying sample type.
This is an implementation of the planned changes described in #119.

For a quick overview of how the API has changed, check out the updated
examples.

**TODO:**

- [x] Update API.
- [x] Update examples.
- [ ] Remove `data_type` field from `Format` (see [here](https://github.com/RustAudio/cpal/issues/119#issuecomment-573788380)).
- Update backends:
  - [x] null
  - [x] ALSA
  - [ ] ASIO
  - [ ] WASAPI
  - [ ] CoreAudio
  - [ ] Emscripten

Closes #119
Closes #260
2020-01-18 15:13:17 +01:00
mitchmindtree
2afebb2806 Clarify the current state of stream behaviour in docs and comments 2019-12-31 16:02:08 +01:00
msiglreith
bfda575218 Port ASIO host to new stream-based API 2019-12-31 15:46:10 +01:00
mitchmindtree
f34a062fac Update docs for removal of the EventLoop 2019-12-31 15:46:10 +01:00
Tatsuyuki Ishi
3cce3e43d9 Change callback interface so that it takes a dedicated error callback 2019-12-31 15:42:35 +01:00
Tatsuyuki Ishi
c97d1dd3fa Remove EventLoop and port the ALSA backend 2019-12-31 15:42:35 +01:00
Ryan Adolf
264cd31b03 Update struct links in crate documentation 2019-12-22 19:22:35 -08:00
mitchmindtree
d9d4a906c9 Switch to dtolnay's thiserror for handling error boilerplate
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.
2019-10-13 12:29:21 +02:00