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.
`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/211https://github.com/rust-windowing/android-ndk-rs/pull/223
* Remove branch in `u16::to_i16` and `i16::to_u16`
If optimizations are at least at level 1, the conversions compile down to the same code as the old one, but if they are turned off, the new code is faster.
* Faster conversion from `f32` to `u16`
The new code is faster in release mode.
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#59Close#348Close#504Close#530Close#538Close#572
* 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()`).
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)
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