23 Commits

Author SHA1 Message Date
mitchmindtree
9c781bd381 Rename stream Format types to Config
This implements the changes described at .

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

Closes .
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
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
58356f49b4 An alternative approach to removing UnknownBufferType.
This is a potential alternative to . This PR is based on .

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 .

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 
Closes 
2020-01-18 15:13:17 +01:00
mitchmindtree
2bf905f3ec
Merge pull request from jbeich/dragonfly
DragonFly support
2020-01-13 15:47:45 +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
Tatsuyuki Ishi
508e7d8ccf Add one missing error handling 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
Luni-4
8234df7f3d Fix clippy 2019-10-04 11:54:11 +02:00
Alex Butler
b1228fc3ff
Alsa: Set buffer size near to 100ms 2019-08-31 13:33:57 +01:00
Tatsuyuki Ishi
a5783d14c5 Use snd_pcm_avail_update 2019-08-24 12:32:19 +09:00
mitchmindtree
d3fdb2dd4b
Merge pull request from derekdreery/relax_buffer_size
Remove the (arbitary) restriction on buffer size
2019-08-10 20:10:24 +02:00
est31
624ca7624f
Update mod.rs ()
Fixes 
2019-08-10 16:42:47 +02:00
est31
268ea6cfbf Remove mem::uninitialized from alsa backend
uninitialized is being deprecated in favour of
MaybeUninit and friends.
2019-08-10 15:08:21 +02:00
Richard Dodd (dodj)
684aa6392a
Update mod.rs
Fixes 
2019-08-04 11:49:15 +01:00
Richard Dodd
1c34dd682e Remove code rather than comment out 2019-07-27 16:41:19 +01:00
Richard Dodd
b7d230150c Remove the (arbitary) restriction on buffer size 2019-07-24 20:43:20 +01:00
Tatsuyuki Ishi
447300101d Small tweak for ALSA underruns
The hardcoded errno was replaced by a constant, and `snd_pcm_prepare` was replaced by `snd_pcm_recover` per best practice (the underlying implementation seems same for now, though).
2019-07-07 19:42:08 +09:00
mitchmindtree
5e4f384992 Refactor Host and related traits into a new traits module
This is a draft implementation of . I'll leave this open for
feedback and potentially better trait naming suggestions or better
solutions in general!

cc @ishitatsuyuki
2019-06-29 14:45:15 +02:00
mitchmindtree
e8a05379c2 [WIP] Introduce a Host API
This is an implementation of the API described at . Please see that
issue for more details on the motivation.

-----

A **Host** provides access to the available audio devices on the system.
Some platforms have more than one host available, e.g.
wasapi/asio/dsound on windows, alsa/pulse/jack on linux and so on. As a
result, some audio devices are only available on certain hosts, while
others are only available on other hosts. Every platform supported by
CPAL has at least one **DefaultHost** that is guaranteed to be available
(alsa, wasapi and coreaudio). Currently, the default hosts are the only
hosts supported by CPAL, however this will change as of landing  (cc
@freesig). These changes should also accommodate support for other hosts
such as jack  (cc @derekdreery) and pulseaudio (cc @knappador) .

This introduces a suite of traits allowing for both compile time and
runtime dispatch of different hosts and their uniquely associated device
and event loop types.

A new private **host** module has been added containing the individual
host implementations, each in their own submodule gated to the platforms
on which they are available.

A new **platform** module has been added containing platform-specific
items, including a dynamically dispatched host type that allows for
easily switching between hosts at runtime.

The **ALL_HOSTS** slice contains a **HostId** for each host supported on
the current platform. The **available_hosts** function produces a
**HostId** for each host that is currently *available* on the platform.
The **host_from_id** function allows for initialising a host from its
associated ID, failing with a **HostUnavailable** error. The
**default_host** function returns the default host and should never
fail.

Please see the examples for a demonstration of the change in usage. For
the most part, things look the same at the surface level, however the
role of device enumeration and creating the event loop have been moved
from global functions to host methods. The enumerate.rs example has been
updated to enumerate all devices for each host, not just the default.

**TODO**

- [x] Add the new **Host** API
- [x] Update examples for the new API.
- [x] ALSA host
- [ ] WASAPI host
- [ ] CoreAudio host
- [ ] Emscripten host **Follow-up PR**
- [ ] ASIO host 

cc @ishitatsuyuki more to review for you if you're interested, but it
might be easier after  lands and this gets rebased.
2019-06-24 21:45:04 +02:00