Commit Graph

72 Commits

Author SHA1 Message Date
mitchmindtree 640a1d39ed Rebase/Update webaudio PR for recent breaking changes
This rebases #372, addressing the recent changes introduced by #397, #395, and #371 in the process.

TODO:

- [ ] Complete implementation of `callback` and `playback` timestamps in the output stream callback.
2020-05-21 16:16:23 +02:00
Damian Peckett 6f43fc2b60 Add a wasm-bindgen based generic Web Audio backend. 2020-05-06 13:44:00 +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
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 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 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 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 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
mitchmindtree 33ddf74954 Explicitly make dynamically dispatched API !Send + !Sync
This is in order to ensure consistent restrictions across platforms in a
manner that ensures thread safety across each of the supported
platforms.

Please see added comments in the diff for details on which platforms
impose these restrictions.
2020-01-05 17:43:14 +01:00
msiglreith bfda575218 Port ASIO host to new stream-based API 2019-12-31 15:46:10 +01:00
mitchmindtree 37d80b98cf Update the `emscripten` backend for the removal of the `EventLoop`
For the most part, behaviour should be largely unchanged, however each
individual stream now has its own `set_timeout` callback loop, rather
than using one for processing all streams at once.

Many TODOs remain within the `emscripten` backend. These were left
untouched for the most part in favour of addressing this in a more
web-focused, future PR.
2019-12-31 15:45:15 +01:00
Tatsuyuki Ishi 70dcf2390a Port CoreAudio backend 2019-12-31 15:45:15 +01:00
Viktor Lazarev f65d0e65bc Expose Stream instead of StreamId 2019-12-31 15:42:35 +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
Tatsuyuki Ishi 984ff0fd30 Add name to HostId 2019-07-18 09:46:50 +09:00
mitchmindtree 6cd7492f4c Add missing `Hash` constraint to `StreamId`
This existed prior to the introduction of the `Host` API, but was lost
in translation. This re-adds the bounds so that downstream code does not
suddenly break due to a lacking `Hash` implementation in the next
CPAL version.
2019-07-05 19:28:34 +02:00
mitchmindtree 714dab7270 Refactor asio message to use a match expr. Fix some typos. 2019-07-05 13:19:42 +02:00
mitchmindtree 7d0f9c7265 Remove unreachable_patterns gate onto relevant fns so all platforms benefit 2019-07-05 05:51:31 +10:00
mitchmindtree 8f95042b8d Add `asio` cargo feature for optional ASIO support
ASIO introduces quite a few extra crates and requires a fairly
complicated setup process (see the readme), so this feature is disabled
by default.
2019-07-05 05:51:30 +10:00
mitchmindtree 05f8b7dc43 Fix remaining compile errors for ASIO host
Now runs the beep and enumerate examples nicely! Time to do a proper
code review of the ASIO stuff and see how to best take advantage of the
new `Host` API.
2019-07-05 05:51:28 +10:00
mitchmindtree 09fd5562be Update ASIO implementation for new error handling and Host API
This is currently untested and will almost certainly not build. I'm
about to move into a Windows VM to get everything running properly
again.
2019-07-05 05:51:28 +10:00
mitchmindtree 2bc9f85970 Update supported_formats methods for all sample rates and channel combos
Closes #32.
2019-07-05 05:51:28 +10:00
Tom Gowan bc94d167ae fix endianess 2019-07-05 05:51:28 +10:00
Tom Gowan f2c8099810 bug fix and comment 2019-07-05 05:51:27 +10:00
Tom Gowan 5eb311d8be float conversion fix 2019-07-05 05:51:27 +10:00
Tom Gowan a3defde208 Checks formats 2019-07-05 05:51:27 +10:00
Tom Gowan c255da24bf stream id bug 2019-07-05 05:51:27 +10:00
Tom Gowan fd808b95e9 indentation and no clean up on destroy stream 2019-07-05 05:51:27 +10:00
Tom Gowan ab3b76ad75 fixes, remove transmute 2019-07-05 05:51:26 +10:00
Tom Gowan 7950045240 minor fixes 2019-07-05 05:51:26 +10:00
Tom Gowan 25070464f9 git ignore, temp files, fetch_add, os cfg 2019-07-05 05:51:26 +10:00
Tom Gowan 523d25ad49 remove u16 2019-07-05 05:51:26 +10:00
Tom Gowan 616974353b opt in and bug fix 2019-07-05 05:51:26 +10:00
Tom Gowan 1f24c76e6a commenting and rustfmt for device 2019-07-05 05:51:26 +10:00
Tom Gowan 5248455cb7 commets and rustfmt for stream 2019-07-05 05:51:25 +10:00
Tom Gowan ffcbc02e52 multi channels 2019-07-05 05:51:25 +10:00
Tom Gowan 6e0eb073d1 sample rate support 2019-07-05 05:51:25 +10:00
Tom Gowan b0b0484d4b endian conversion 2019-07-05 05:51:25 +10:00
Tom Gowan 5ec6da3aad Fixed driver bug 2019-07-05 05:51:24 +10:00
Tom Gowan 6a71f0a801 choose backend 2019-07-05 05:51:24 +10:00
Tom Gowan 91f2edb277 utils as mod 2019-07-05 05:51:24 +10:00
Tom Gowan ed50bb9923 adding outputs 2019-07-05 05:51:24 +10:00
Tom Gowan ff7fd62a2d clean up 2019-07-05 05:51:24 +10:00
Tom Gowan 93f75940d6 fixed offset bug 2019-07-05 05:51:24 +10:00
Tom Gowan 8193bc9f79 sharing asio streams 2019-07-05 05:51:24 +10:00