26 Commits

Author SHA1 Message Date
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
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
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
009b796b7c Update wasapi backend for SupportedStreamConfig private fields 2020-02-02 19:06:16 +01:00
mitchmindtree
07b66f52f3 Rename FormatNotSupported to StreamConfigNotSupported 2020-01-28 22:55:43 +01:00
mitchmindtree
e0da586f77 Update wasapi backend for stream format renaming 2020-01-28 00:26:15 +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
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
1b5cf579cb Update WASAPI backend for addition of new stream Data type 2020-01-19 19:17:40 +01:00
mitchmindtree
b5bfb8d422 Update WASAPI backend for removal of UnknownTypeBuffer 2020-01-18 15:13:17 +01:00
Viktor Lazarev
64ba84de81 Move code from stream to device 2019-12-31 15:46:10 +01:00
Tatsuyuki Ishi
7f7914434c Additional clippy fixes 2019-12-31 15:42:35 +01:00
Viktor Lazarev
d46415a6e7 cargo clippy 2019-12-31 15:42:35 +01:00
Tatsuyuki Ishi
49a38c2641 Fix up WASAPI host 2019-12-31 15:42:35 +01:00
Viktor Lazarev
d4965d3673 cargo fmt 2019-12-31 15:42:35 +01:00
Viktor Lazarev
c62cb48e19 Apply suggestions proposed by Clippy 2019-12-31 15:42:35 +01:00
Viktor Lazarev
a218dc90e6 Fixing compile errors 2019-12-31 15:42:35 +01:00
Viktor Lazarev
1021141d16 Fix "build_input/output_stream_inner" methods 2019-12-31 15:42:35 +01:00
Viktor Lazarev
d12d9f479b Remove redundant field names 2019-12-31 15:42:35 +01:00
Viktor Lazarev
e25c44a4a1 Move code from stream to device 2019-12-31 15:42:35 +01:00
Viktor Lazarev
37e7b5b63b Move DeviceTrait implementation to wasapi::device 2019-12-31 15:42:35 +01:00
lucy
dcabad105b Implement WASAPI loopback support
This works by detecting output devices in build_input_stream() and
setting the AUDCLNT_STREAMFLAGS_LOOPBACK flag to enable loopback
recording.

closes #251
2019-10-27 14:52:12 +01:00
Tom Gowan
6e0eb073d1 sample rate support 2019-07-05 05:51:25 +10:00
mitchmindtree
e8a05379c2 [WIP] Introduce a Host API
This is an implementation of the API described at #204. 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 #221 (cc
@freesig). These changes should also accommodate support for other hosts
such as jack #250 (cc @derekdreery) and pulseaudio (cc @knappador) #259.

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 #221

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