Commit graph

205 commits

Author SHA1 Message Date
general electrix
0af6a1c466 Refactor disconnection to trigger error_callback. 2022-10-11 02:55:03 -07:00
general electrix
baa697c7fc Implement disconnection detection for CoreAudio on MacOS.
* Create AudioObjectPropertyListener type, providing an easy way to attach a Rust callback.
* Refactor the existing sample rate update mechanism to use AudioObjectPropertyListener.
* Add an optional property listener that registers a callback that is triggered on device disconnection.
* Create a set_on_disconnect method to register the disconnection callback.
2022-10-09 13:29:04 -07:00
pin
73a035617b
Fix CI failure (#705) 2022-10-08 14:55:50 +02:00
Kai Giebeler
85d773d59f Migrate Sample to dasp_sample (#689) 2022-10-07 14:08:54 +02:00
pin
0f8cd7a9c8 Add NetBSD support 2022-09-25 07:54:19 +02:00
Kai Giebeler
e78a847272 fix some clippy warnings 2022-09-20 21:51:20 +02:00
Kai Giebeler
08acedd677 fix towards edition 2021 2022-09-20 21:47:35 +02:00
Osspial
417b7fff6f
Implement BufferSize::Fixed in wasapi, and migrate wasapi to officially-supported Windows crate (#669)
I migrated to `windows-rs` in this PR since exposing the buffer size range for hardware-offloaded audio processing requires `IAudioClient2`, which isn't exposed in the `winapi` crate, and `winapi` seems to be more or less unmaintained at this point.

* Basic type conversion

* Make everything compile!

* Fix warnings

* Implement buffer sizing for wasapi

* Convert tabs to spaces

* Run cargo fmt

* Remove winapi from Cargo.toml

* Remove unused commented code from wasapi, and fix lingering TODOs

* Fix compile error

* Update to windows 0.37.0

* Run rustfmt

* Work around rustfmt nested tuple issues

* Improve readability of guid comparison code
2022-07-15 14:59:45 +02:00
alula
32cee3949b
Return Device(None) as a default i/o device (#638)
In most cases, device with index 0 is NOT the default output device - in my case it happens to be the ear speaker. Returning Device(None) there makes Oboe choose the default input/output device - everything works as expected.
2022-06-07 07:46:24 +02:00
James Liu
223f28262a
Update dependencies, switch to once_cell (#673) 2022-06-06 02:18:23 +02:00
Rodrigo Batista de Moraes
b1457e5945
webaudio: expose AudioContext in WebAudioStream (#659) 2022-04-26 03:21:41 +02:00
Luca Barbato
a540a98b0a Fallback to monotonic timestamp if monotonic_raw can be set up
Fixes #606
2022-03-22 21:24:41 +01:00
Kai Hagseth
d50e0ecbac fix: follow default output source on mac osx
When playing out on default output source, follow the default output
source chosen in sound preferences in osx.
2022-02-28 09:37:17 +01:00
Dimitris Apostolou
1cd0caf8b6
Fix typos 2022-02-19 18:14:34 +02:00
Rémi Lauzier
8b99fce094
Rust 2021 and clap 3.0 2022-02-18 03:24:43 -05:00
Marijn Suijten
f8b05ade39 android: Migrate from ndk-glue to ndk-context
`ndk-glue` suffers one fatal flaw: it's "only" supposed to be used by
the crate providing `fn main()` and only supposed to end up in the
dependency graph once as it has `static` globals which get duplicated
across versions.

In the current case with `winit 0.26` still on `ndk-glue 0.5` but
`cpal` on `ndk-glue 0.6` it'll always panic in `fn native_activity()` as
the `static` globals on this version is not initialized.

Introducing `ndk-context`: a crate that holds these `static`s, with the
intention/premise to not see a breaking release /ever/ and make this a
problem of the past.  The crate is currently initialized with the VM and
Android Context on `ndk-glue` 0.5.1 and 0.6.1 (0.4.1 pending) making it
compatible with whatever is current, and the possibility for backporting
to older `ndk-glue` versions too.

See also:
https://github.com/rust-windowing/android-ndk-rs/issues/211
https://github.com/rust-windowing/android-ndk-rs/pull/223
2022-02-15 16:52:20 +01:00
nyanpasu64
1edf930bb4
Cleanup and document cpal's ALSA backend (#629) 2022-01-22 22:38:13 +01:00
hyranno
241b495f44 fix: driver.prepare_output_stream should take streams.input 2021-12-01 12:55:38 +09:00
est31
8e616c3dd9 Update alsa and nix dependencies
Also fixes the build.
2021-10-31 23:37:27 +01:00
Tatsuyuki Ishi
03947afefb wasapi: Allow both threading models and switch the default to STA
COM can prevent undefined behavior in either concurrency model by
performing marshaling when necessary. As a result, CoInitializeEx can be
called with either concurrency model, and in this case STA provides better
compatibility with other code requiring STA, e.g. ASIO backend or winit
drag-and-drop.

To dive into the detail, the entry point of WASAPI, MMDeviceEnumerator, is
registered with "both" threading model, which means that COM objects are
created with whatever the thread's concurrency model is set to. This raises
the concern that when STA is used, marshaling might make audio buffer
operations block on the main thread, breaking continuous audio processing.
However, the implementation actually uses free-threaded marshaller for
interfaces dealing with buffer operations, which effectively bypasses COM's
compatibility marshaling behavior and perform any API calls on the caller's
thread instead. Therefore, the interfaces would operate just fine on either
concurrency model.

For more details on COM's threading model, see [1].

[1] https://thrysoee.dk/InsideCOM+/ch04d.htm

Co-Authored-By: Henrik Rydgård <hrydgard@gmail.com>

Close #59
Close #348
Close #504
Close #530
Close #538
Close #572
2021-08-08 12:03:18 +09:00
Rémi Lauzier
ba462dad18
Fix some typo and warnings 2021-06-29 11:30:26 -04:00
Rémi Lauzier
6c78dce4c1
fix some clippy warnings 2021-06-25 18:07:05 -04:00
Alex Moon
c349eb1477 [ALSA] Improve stream setup parameters.
* Always set period before setting buffer size, even if
  `BufferSize::Fixed`.
* Set `start_threshold` based on `alsa::Direction` to avoid underruns on
  playback streams.

Also refactor the return values of the set params functions to reflect their
actual use and resolve some clippy warnings (including a logic error in
`stream_timestamp()`).
2021-06-17 17:09:26 +02:00
est31
47ef62d413
Merge pull request #567 from RustyDAW/jack-alloc
Update to rust-jack 0.7 and simplify implementation
2021-06-07 08:47:18 +02:00
Marko Mijalkovic
d6236adb84 Remove unimplemented size hint 2021-05-11 18:21:06 -04:00
Roope Salmi
833acbae61 Update to rust-jack 0.7 and simplify implementation
With rust-jack 0.7, the buffer_size callback is moved to
ProcessHandler. This reflects how it is actually called by jack:
it is called synchronously on the process thread, but it is allowed to
perform non-real-time-safe operations. In CPAL, this means that
it is fine to reallocate the temporary interlacing buffers when buffer
size changes.

This removes the need for buffer splitting on the output stream type,
and prevents panics when buffer size is made larger than initially on
the input stream type. (for some reason, buffer splitting was not
implemented for input previously)
2021-04-04 03:53:25 +03:00
est31
5837ceb58f
Merge pull request #562 from JCapucho/fix-alsa-distortion
Fix alsa in some configs outputting bad audio
2021-03-29 11:38:20 +02:00
Marcel Märtens
a945d83ac7 give each thread a unique name 2021-03-22 11:06:15 +01:00
Marcel Märtens
f9720b9767 clippy fixes 2021-03-22 10:59:08 +01:00
João Capucho
52821d9c37
Fix alsa in some configs outputting bad audio
This was introduced in 6b91485 and could cause issues with some alsa
configurations like that of pipewire-alsa which caused the audio to be
become weirdly distorted
2021-03-19 22:04:32 +00:00
Michael Hills
b9b36d6a9a iOS default sample rate pulled from audio unit 2021-01-02 02:04:13 +11:00
Michael Hills
2cccf99d50 Refactor coreaudio host and add iOS support + ios-feedback example 2021-01-02 02:04:13 +11:00
Alex Moon
9c4e240a7c Further refactoring of DeviceHandles.
Also fixes rustaudio/cpal#515.
2020-12-09 08:38:25 -07:00
Alex Moon
b89df31797 Refactor ALSA handle manipulation into methods on DeviceHandles. 2020-12-07 16:16:50 -07:00
Alex Moon
fb30d291ce Avoid calling alsa::PCM::new() multiple times.
Ensures that alsa::PCM::new() is called only once for a given Device so that we are
not rapidly opening and closing ALSA devices.
2020-11-18 10:22:41 -07:00
est31
a65e028412 Update alsa requirement to 0.4.3 and change io to io_bytes 2020-11-08 21:34:20 +01:00
Sergej Jurečko
3d163c3468 fix panic on windows if device gets unplugged 2020-11-05 09:24:00 +01:00
mitchmindtree
2220f58491
Merge pull request #491 from creator-rs/master
Add Android APK build CI and Release version 0.13.0
2020-11-03 13:03:47 +01:00
enfipy
bf766c1d5d
Update oboe to newest version. Fix support of input/output oboe streams 2020-10-29 19:32:11 +02:00
mitchmindtree
c3fce0bc7b
Merge pull request #452 from darakshan/master
Eliminate or suppress Clippy messages.
2020-10-27 23:36:28 +01:00
mitchmindtree
70408a92ec
Merge pull request #478 from dheijl/master
Re-enable WasApi loopback capture
2020-10-27 23:33:44 +01:00
mitchmindtree
f8775b1e7b
Merge pull request #468 from endragor/android-support
Android support via Oboe
2020-10-27 12:26:33 +01:00
dheijl
621d99ba56
Merge pull request #4 from RustAudio/master
Sync with rustaudio cpal
2020-10-25 12:53:30 +01:00
Johnny Egeland
43d7363aa2 Fixed error in sub-second nanos calculation which caused overflow panic 2020-10-25 11:15:54 +01:00
Ruslan Mustakov
4e9d27266c Android support via Oboe 2020-10-24 15:42:21 +07:00
dheijl
f4621de3a3
Merge pull request #2 from RustAudio/master
JACK Host (#389)
2020-10-01 12:35:40 +02:00
Erik Natanael Gustafsson
2b31fe41af
JACK Host (#389)
Co-authored-by: Federico Dolce <psykopear@gmail.com>
2020-10-01 18:04:43 +09:00
dheijl
1e9689ef48 rust format --all 2020-09-20 17:00:51 +02:00
dheijl
0d37421b45 rust format 2020-09-20 16:01:59 +02:00
dheijl
1f4d7b04c9
Merge pull request #1 from RustAudio/master
Merge with Rustaudio/cpal
2020-09-12 12:53:46 +02:00