Commit Graph

110 Commits

Author SHA1 Message Date
Viktor Lazarev c62cb48e19 Apply suggestions proposed by Clippy 2019-12-31 15:42:35 +01:00
Viktor Lazarev 10dc779943 Return back missed play/pause implementation 2019-12-31 15:42:35 +01:00
Viktor Lazarev a218dc90e6 Fixing compile errors 2019-12-31 15:42:35 +01:00
Viktor Lazarev a412b00336 Fix the "Stream::new' method 2019-12-31 15:42:35 +01:00
Viktor Lazarev e7f708701c Remove old code 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 f65d0e65bc Expose Stream instead of StreamId 2019-12-31 15:42:35 +01:00
Viktor Lazarev 125bebd733 Clean up wasdapi mod 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 7765e941ed Implement Drop for Stream 2019-12-31 15:42:35 +01:00
Viktor Lazarev 0541bf8667 Add Stream struct 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 dd418c08ae Adjust "process_commands" and "Command" 2019-12-31 15:42:35 +01:00
Viktor Lazarev 28cf3fee43 Fix "run_inner" fn 2019-12-31 15:42:35 +01:00
Viktor Lazarev b00630bdcc Extract "run_inner" as a standalone function 2019-12-31 15:42:35 +01:00
Viktor Lazarev 463540f370 Keep a single stream only 2019-12-31 15:42:35 +01:00
Viktor Lazarev cffd2da582 Rename "StreamDataResult" to "StreamData" 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
Tatsuyuki Ishi e782ca1ac8 Suppress warnings in null backend 2019-12-31 15:42:35 +01: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
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
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
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
est31 447ad5d727
Merge pull request #321 from RustAudio/wasapi-capture
Fix WASAPI capture logic
2019-08-14 00:42:08 +02:00
ishitatsuyuki e9043c605a Fix WASAPI capture logic
The buffer size handling differs from what render streams uses. Logic is based on https://github.com/microsoft/Windows-universal-samples/blob/master/Samples/WindowsAudioSession/cpp/WASAPICapture.cpp.
2019-08-12 10:56:14 +09:00
mitchmindtree d3fdb2dd4b
Merge pull request #307 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 (#314)
Fixes #309
2019-08-10 16:42:47 +02: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
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 #309
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 64dc6accf9 Rebase for the trait refactor in #295. 2019-07-05 06:03:33 +10:00
mitchmindtree cc5b0555c2 Refactor of asio-sys while reviewing for code correctness
Most of this is an attempt at improving readability and modularity of
the asio-sys crate while attempting to review it for correctness. Still
unsure why glitching is occasionally occuring on output, but recorded
input sounds perfectly clean.
2019-07-05 05:51:31 +10:00
mitchmindtree 9182f00e20 Check that sample format is supported by ASIO when building streams 2019-07-05 05:51:31 +10:00
mitchmindtree c432f2b18d Update asio-sys to allow for having multiple handles to the same driver
ASIO has a limitation where it only supports loading a single audio
driver at a time. This fixes a common error where CPAL users would
request both the default input device and output device in separate
`load_driver` calls. Now, `load_driver` will return another handle to
the existing driver if the existing driver has the same name.
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 191b90909a Make Driver type responsible for managing user callbacks 2019-07-05 05:51:30 +10:00
mitchmindtree 4dafb212fb Refactor build_input_stream callback to, like recent output refactor 2019-07-05 05:51:30 +10:00
mitchmindtree cc70a10c12 Remove unused supported_formats_err function 2019-07-05 05:51:29 +10:00
mitchmindtree dc6c5c5a7c Remove unnecessary asio_utils mod 2019-07-05 05:51:29 +10:00
mitchmindtree 50aa0585be Remove unwieldy macro from output stream callback
Instead, we use some traits and generics in an attempt to retain a
little readability. See the remaining TODOs in this section for required
future work.
2019-07-05 05:51:29 +10:00
mitchmindtree d739a5b79d Majority of ASIO host update following refactor
Currently not compiling - still need to address some global items within
asio-sys, including the `set_callback` function and the double buffer
globals.
2019-07-05 05:51:29 +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
Tom Gowan 6e0eb073d1 sample rate support 2019-07-05 05:51:25 +10: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 e131979d22 Update README for addition of host enumeration API 2019-06-25 00:39:51 +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 6b6830ab57 Implement `Host` API for emscripten backend 2019-06-24 22:38:48 +02:00
mitchmindtree 69cd058d28 Implement new `Host` API for WASAPI backend 2019-06-24 22:21:19 +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