Commit graph

545 commits

Author SHA1 Message Date
mitchmindtree
cdf23c3c62 Add stream timestamp implementation to WASAPI backend
This was written on Linux and while the code type-checks, it has not yet
been tested.
2020-04-29 14:59:25 +02:00
mitchmindtree
79a0020c88 Add timestamp implementation to emscripten backend 2020-04-29 14:58:08 +02:00
mitchmindtree
54e5e95705 WIP Add timestamp implementation to coreaudio backend
Currently a rough estimate of the required work, not yet tested.
2020-04-28 17:48:25 +02:00
mitchmindtree
163f0cc190 Move reference to timestamp validity bug to more suitable location 2020-04-28 17:43:40 +02:00
mitchmindtree
45977bf837 Add fallback instant source to ALSA backend
Here we use `std::time::Instant` as a fallback source for stream
instants in the case that the device produces invalid timestamps via
`get_htstamp`.
2020-04-28 17:40:40 +02:00
mitchmindtree
a49297ec2c WIP - Add ALSA timestamp implementation.
I think this is mostly complete, however there are two major TODOs:

- There seems to be a bug where timestamps are not reported when the
  target device is `pulse`. This causes a `panic!` as the trigger
  timestamp should always precede the timestamp when retrieved while the
  stream is running.
- We need to specify the timestamp type as MONOTONIC_RAW, however the
  `alsa` and `alsa-sys` crates do not yet expose the necessary
  `set_tstamp_type` function.
2020-04-28 17:38:44 +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
f032557fb4
Merge pull request #395 from mitchmindtree/callback_info
Add a `CallbackInfo` argument to the stream data callback
2020-04-27 14:32:37 +02:00
mitchmindtree
aae44cf3d6 Fix process_callback function signatures in asio backend 2020-04-16 15:30:14 +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
Richard Dodd
3c3349f926 Add some comments. 2020-04-15 18:46:54 +01:00
Richard Dodd
290f464330 Cargo fmt 2020-04-15 18:42:43 +01:00
Richard Dodd
86079e6439 Rebase off new alsa-rs impl 2020-04-15 18:41:40 +01:00
Alex Moon
b386e63eec Ignore play/pause errors for ALSA Stream 2020-04-12 13:11:35 -04:00
Alex Moon
62d540d396 Switch from vendored alsa-sys to alsa crate 2020-04-03 16:56:51 -04: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
9bf5664f7d Update wasapi and emscripten backends for SupportedStreamConfig private fields 2020-02-02 19:56:30 +01:00
mitchmindtree
009b796b7c Update wasapi backend for SupportedStreamConfig private fields 2020-02-02 19:06:16 +01:00
mitchmindtree
f05ba58207 Update emscripten backend for SupportedStreamConfig private fields 2020-02-02 18:50:12 +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
07b66f52f3 Rename FormatNotSupported to StreamConfigNotSupported 2020-01-28 22:55:43 +01:00
mitchmindtree
f292391190 Update asio backend for stream format renaming 2020-01-28 16:17:14 +01:00
mitchmindtree
3a692f8bca Update coreaudio backend for stream format renaming 2020-01-28 15:03:27 +01:00
mitchmindtree
e0da586f77 Update wasapi backend for stream format renaming 2020-01-28 00:26:15 +01:00
mitchmindtree
669aada98a Update emscripten backend for stream format renaming 2020-01-27 21:44:52 +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
e7979d2dfe Fix some strangely formatted commented code 2020-01-21 00:15:52 +01: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
a7008b63a5 Address deprecated mem::uninitialized warnings in WASAPI host
This uses `ptr::null_mut()` and `MaybeUninit` to remove use of
deprecated `mem::uninitialized()` which could possibly result in UB.
2020-01-20 20:22:15 +01:00
mitchmindtree
64f8fd12cc Update CoreAudio host for the addition of the new stream Data type 2020-01-19 19:42:43 +01:00
mitchmindtree
c0a28b5198 Update ASIO host for addition of new stream Data type. 2020-01-19 19:35:35 +01:00
mitchmindtree
1b5cf579cb Update WASAPI backend for addition of new stream Data type 2020-01-19 19:17:40 +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
7f27b897bb Update emscripten backend for new stream Data type 2020-01-19 16:04:06 +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
6fbb701826 Update CoreAudio backend for removal of UnknownBufferType 2020-01-18 15:15:41 +01:00
mitchmindtree
9e832c6eb3 Update ASIO backend for removal of UnknownBufferType 2020-01-18 15:13:17 +01:00
mitchmindtree
b5bfb8d422 Update WASAPI backend for removal of UnknownTypeBuffer 2020-01-18 15:13:17 +01:00
mitchmindtree
5a619877f9 Update docs for removal of UnknownTypeBuffer 2020-01-18 15:13:17 +01:00
mitchmindtree
6fc2185c99 Update emscripten backend 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
Alex Moon
1b10f92f9d Fix undeclared module errors on Mac. 2020-01-16 12:24:33 -08:00
mitchmindtree
2bf905f3ec
Merge pull request #358 from jbeich/dragonfly
DragonFly support
2020-01-13 15:47:45 +01:00
mitchmindtree
32d39bcfd3 Relax Sync restriction on Device and Host
Originally this restriction was placed due to uncertainty around the
thread safety of the ASIO API. While the ASIO API itself makes no
thread-safety guarantees that we are aware of, the `asio-sys` high-level
bindings enforce synchronised access to the API and state transitions
via a mutex.
2020-01-12 22:43:05 +01:00
Jan Beich
3ac6f6a689 Enable ALSA on DragonFly
DragonFly like FreeBSD uses OSS under the hood but OSS backend isn't
available, so use ALSA.
2020-01-07 16:18:52 +00:00