Commit Graph

25 Commits

Author SHA1 Message Date
JoshuaBatty 6edee6c6c2 coreaudio buffersize wip 2020-05-26 14:55:55 +02:00
JoshuaBatty 7081c3bbd6 wip alsa buffersizes 2020-05-26 14:55:55 +02:00
ely-uf d9136708e4 Fix CoreAudio warnings.
1) warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
2) warning: unnecessary `unsafe` block
3) warning: field is never read: `device_id`
2020-05-26 02:29:49 +03:00
mitchmindtree fe22704d4a
Merge pull request #397 from mitchmindtree/timestamp
[WIP] Timestamp and `StreamInstant` APIs
2020-05-05 15:33:55 +02:00
JoshuaBatty 590d37b103 fixes compile errors for coreaudio timestamp work 2020-05-01 15:20:37 +02:00
Thomas Havlik e4eb7169ef
macOS: fallback to CFStringGetCString if CFStringGetCStringPtr returns nil (#399)
* macOS: fallback to CFStringGetCString if CFStringGetCStringPtr returns nil; fixes #398

* rustfmt

Co-authored-by: Tom Havlik <thomashavlik@Adams-Mac-mini.local>
2020-05-01 09:38:25 +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 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 9bf5664f7d Update wasapi and emscripten backends for SupportedStreamConfig private fields 2020-02-02 19:56:30 +01:00
mitchmindtree 07b66f52f3 Rename FormatNotSupported to StreamConfigNotSupported 2020-01-28 22:55:43 +01:00
mitchmindtree 3a692f8bca Update coreaudio backend for stream format renaming 2020-01-28 15:03:27 +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 64f8fd12cc Update CoreAudio host for the addition of the new stream `Data` type 2020-01-19 19:42:43 +01:00
mitchmindtree 6fbb701826 Update CoreAudio backend for removal of `UnknownBufferType` 2020-01-18 15:15:41 +01:00
Alex Moon 1b10f92f9d Fix undeclared module errors on Mac. 2020-01-16 12:24:33 -08:00
Tatsuyuki Ishi 70dcf2390a Port CoreAudio backend 2019-12-31 15:45:15 +01:00
Sebastian Imlay d8743b34ce Fixed compiler warnings
* Removed extra semi-colon
* Added dyn where requested
* Removed ::std:: in thead::sleep call.
2019-12-29 15:02:34 -08:00
est31 14c1258a57 Remove uninitalized from coreaudio backend
uninitialized is being deprecated in favour of
MaybeUninit and friends.

In fact, using mem::zeroed() here is the
initialization method that apple docs recommend.

https://developer.apple.com/documentation/coreaudiotypes/audiostreambasicdescription
2019-08-10 15:40:34 +02:00
mitchmindtree 5e4f384992 Refactor `Host` and related traits into a new `traits` module
This is a draft implementation of #294. 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 3603cbaee7 Remove macOS sleep loop in favour of using `Condvar`
This solution was originally posted by @HybridEidolon in #185. Sorry it
took so long! I thought it might be easier to open a new PR as half of
your implementation here has already been implemented in a following PR
(namely, the change from an unnecessary `Vec` of callbacks to a single
user callback).

Closes #185.
2019-06-25 17:38:54 +02:00
mitchmindtree 283a73054e Address some nits highlighted by ishitatsuyuki 2019-06-25 16:26:27 +02:00
mitchmindtree 6e9b40e225 Minimize compiler flags by using nested platform_impl mods
Also addresses some other CI errors:

- Add Host::new constructor for null backend
- Add missing DevicesError import to coreaudio backend
2019-06-24 23:22:37 +02:00
mitchmindtree f7cf0c65b8 Implement `Host` API for coreaudio backend 2019-06-24 22:44:57 +02: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