Граф коммитов

1057 Коммитов

Автор SHA1 Сообщение Дата
Andreas Pehrson d5e7769e48
Don't use VPIO forcelist by default (#244)
This makes it so clients have to opt into the VPIO forcelist.
It is currently mainly needed by gecko, since sites may create multiple
streams to a builtin device with different prefs and processing params,
and HAL audio units to builtin device are not working properly when
there is a VPIO audio unit to the same builtin device on (anywhere) on
the system.

With the cfg flag vpio-forcelist a client can avoid VPIO altogether, by
not compiling with the flag, and by never creating input streams with
the VOICE pref.

Should a client need to mix VOICE and non-VOICE input streams to a
single device, it should enable vpio-forcelist.

Fixes #242.
2024-11-20 12:03:30 +13:00
Miriam Zimmerman 87024ed394 Pass gecko-in-tree feature to cubeb-backend.
This lets us break a circular dependency when cubeb includes
cubeb-coreaudio-rs.
2024-11-20 11:43:58 +13:00
Miriam Zimmerman 28166fb5f2 Fix stereo -> mono downmixing.
Rather than summing the two channels, average them. This prevents
integer overflow and clipping or needlessly increasing volume.
2024-10-23 09:25:45 -07:00
Miriam Zimmerman f70ef45e66 cargo fmt 2024-10-11 12:42:13 +13:00
Miriam Zimmerman 9ea926bf36 Automatically fix some new nightly clippy warnings. 2024-10-11 12:42:13 +13:00
Miriam Zimmerman 3642fca704 Ignore manual_c_str_literals warning.
Due to https://github.com/rust-lang/rust-clippy/issues/13531, this
incorrectly applies here on nightly builds of clippy -- it should not,
since this project is on edition 2015 by default.
2024-10-11 12:42:13 +13:00
Miriam Zimmerman d9fd2fec7a Fix trivial clippy errors, silence nontrival ones. 2024-10-11 12:42:13 +13:00
Miriam Zimmerman 78093aba60 Add empty [workspace] to Cargo.toml.
This works around https://github.com/rust-lang/cargo/issues/6745 and
allows cubeb-coreaudio-rs to appear as a subdirectory of a workspace
member in another project (for instance, cubeb-rs).
2024-10-11 12:42:13 +13:00
Andreas Pehrson 2407441a2f Block Studio Display Mic for input-only when its Speakers are default output
The VPIO unit behaves the same when not setting an output as when
setting the default output device as output.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1914925.
2024-09-16 15:59:43 +02:00
Andreas Pehrson f7e50c2166 Set output_dev_desc correctly when deciding to skip the mixer 2024-08-13 06:45:37 -07:00
Andreas Pehrson 4a2ef4684f Use different scopes on the output bus depending on AudioUnit type 2024-08-13 06:45:37 -07:00
Paul Adenot 0f642c8d50 Restore some state in case of reinit failure when device has changed while paused, or when starting fails 2024-08-09 16:39:56 +02:00
Paul Adenot 8b708e90f1 Tighten the device-switch-while-paused test: check that the devices are the ones we expect before and after switching 2024-08-09 16:39:56 +02:00
Paul Adenot e13c16f9e4 When the device in use by a stream changes but the stream is pause, reinitialize the stream next time it is started 2024-08-09 16:39:56 +02:00
Paul Adenot bd11e7582d Add a test that switches the device while a stream is paused, both manual and automated 2024-08-09 16:39:56 +02:00
Paul Adenot 8fa685bb63 Add some logging around reinitialization 2024-08-09 16:39:56 +02:00
Chun-Min Chang e143e87de1 Add device info to the placeholder in the vpio log 2024-08-06 15:07:30 -07:00
Chun-Min Chang 45a6ff1e06
Using `map_err` over `inspect_err` (#231)
This patch fixes clippy::manual-inspect error. See [1] for details.

[1] https://rust-lang.github.io/rust-clippy/master/index.html#/manual_inspect
2024-08-06 11:38:48 -07:00
Andreas Pehrson 8bce3b333a Init host_time_to_ns_ratio with context
The current HOST_TIME_TO_NS_RATIO implemented with lazy_static is
causing what appears to be false-positive TSAN errors. OnceLock and
LazyLock exhibit similar errors under TSAN.

It seemed easier to rewrite host_time_to_ns_ratio to be a init-once
context member, rather than making the unstable `no_sanitize` attribute
work. Being unstable it also needed to be included conditionally only
when compiled with the nightly compiler. And trying the rustversion
crate for this resulted in compilation failure due to TSAN reporting it
doesn't work...
2024-06-26 11:53:53 +02:00
Andreas Pehrson 4a44ddc703 Skip processing of output render callbacks with 0 frames
Speculative fix for
https://bugzilla.mozilla.org/show_bug.cgi?id=1902989.
2024-06-26 11:53:53 +02:00
Paul Adenot 6d84f46385 Route to the stereo pair even when having an input 2024-06-18 16:50:21 +02:00
Andreas Pehrson b5dc6e2431 Use different scopes on the input bus depending on AudioUnit type 2024-06-17 15:39:31 +02:00
Andreas Pehrson 9ea3d3455d Only apply VPIO properties while running
An Apple bug breaks, at least, the bypass property if it is set prior to
starting the VPIO unit. Broken here means that the property can be set
to any value later while running, without having an effect.

The VPIO defaults is bypass OFF and AGC ON. Starting like that and then
turning on bypass as requested is not going to cause an unexpected
glitch. We reset the VPIO to defaults before stopping so that on reuse
it doesn't risk causing a glitch either.
2024-06-17 12:10:23 +02:00
Andreas Pehrson f8a4ec05e5 Handle unknown aggregate sub devices 2024-06-17 12:09:59 +02:00
Andreas Pehrson 1796ace5bd Report 1 channel for builtin input devices
The builtin mic is always mono. Except when VPIO is live somewhere on
the system, as it is then 3, at least on modern MacBooks (with a mic
array). For this reason, and that mixing those 3 channels does not
result in good audio, we already force VPIO with the builtin mic. To
properly pass tests on a local machine with a builtin mic, and to have
clients not be fooled in a way resulting in us having to upmix input
audio, we override the builtin mic's reported channel count and always
report 1.
2024-05-31 17:57:24 +02:00
Andreas Pehrson 0ee1e1d2fa Return both a stream's id and its owning device id from get_device_streams
This could be useful if a caller needs to filter something based on the
owning device's properties, and is not possible to put outside of
get_device_streams since it could get the streams from a sub device, in
case streams were requested on an aggregate device.
2024-05-31 17:57:24 +02:00
Andreas Pehrson fc8442278d Filter input streams by ID
Empirical testing has shown that stream IDs lie between their owning
device's device ID and the next higher device ID. This commit uses this
knowledge to filter out VPIO input tap streams (really they're loopbacks
of some output stream) from devices because the VPIO tap streams have
IDs between the VPIO device's ID and the next higher device ID.

Regular aggregate devices are an exception as the tap streams appear to
take the place of the real input streams (by judging at their channel
count) and the real input streams get IDs that seem to belong to the
VPIO device. To solve this we enumerate the aggregate's sub devices and
return all their input streams, filtered per above. This should be
enough for every stream property except StartingChannel (it needs to be
in the context of the right device for obvious reasons) which we don't
use.
2024-05-31 17:57:24 +02:00
Andreas Pehrson b364678807 Add test case for enumerating channel count on an aggregate device's input streams with VPIO
The stream IDs on an aggregate device behave differently than a on a regular
device when creating a VPIO unit. This adds a test case for the specific
case with an aggregate devices.
2024-05-31 17:57:24 +02:00
Andreas Pehrson 0c61ac5dda Add test case for enumerating channel count on input streams with VPIO 2024-05-31 17:57:24 +02:00
Andreas Pehrson 59275c31be Rewrite test_aggregate_get_sub_devices
This commit makes it create an aggregate device so that there is always
one device to test get_sub_devices on.
2024-05-31 17:57:24 +02:00
Andreas Pehrson 108cd5cafd Don't assert in test_aggregate_get_sub_devices_for_a_unknown_device
Since it is expected to panic without the assert, the assert simply adds
a way to mask a regression, since it can also cause a panic.
2024-05-31 17:57:24 +02:00
Andreas Pehrson 4f31e7539f Rename AggregateDevice::get_sub_devices
This names it get_sub_devices_or_self to better reflect its semantics.
It is useful in some cases but not in others, so a new get_sub_devices
that does not fall back to return itself is also added. This simplifies
some tests.
2024-05-31 17:57:24 +02:00
Andreas Pehrson 37581a6baf Move audiounit_get_devices to device_property.rs and rename get_devices 2024-05-31 17:57:24 +02:00
Andreas Pehrson 891725676a Remove terminal type getter 2024-05-31 17:57:24 +02:00
Andreas Pehrson ecfba99886 Remove input stream terminaltype filtering 2024-05-31 17:57:24 +02:00
Paul Adenot 4cc24c7dc7 Add debug printouts before running the manual test for mono and stereo 2024-05-28 17:27:42 +02:00
Paul Adenot f910e70d12 Add a smoke test for mono and stereo playback 2024-05-28 17:27:42 +02:00
Paul Adenot b98b6254fc When playing stereo, address the channels by name rather than using index 0 and 1 2024-05-28 17:27:42 +02:00
Andreas Pehrson 0989726a1b Make AudioUnitStream::stopped handling race-safe
This helps avoid some extraneous state callbacks in some cases.
2024-05-22 17:18:35 +02:00
Andreas Pehrson c6ce6c20d5 In reinit(), exit early if something stopped the stream
Reinit is inherently racy. It can be triggered async by the input
callback, and the output callback can, between the input callback and
reinit(), set the `stopped` flag. In this case, there is no need to
continue with the reinit.
2024-05-22 17:18:35 +02:00
Andreas Pehrson 3563964531 In input callback never reinit if data callback told us to stop 2024-05-22 17:18:35 +02:00
Andreas Pehrson c5d04f2a43 Add a test case reinit_async
The order of events we want to mimic is:
- input callback
  - reinit_async
- output callback
  - data callback error -> state_callback(error)
- reinit
  - setup error -> state_callback(error)

For a particular stream these events should result in only one
state_callback(error).
2024-05-22 17:18:35 +02:00
Andreas Pehrson d472f1b80a On Github Actions install blackhole-2ch on macOS-12
It was removed in https://github.com/actions/runner-images/pull/9487
2024-05-21 15:29:57 +02:00
Andreas Pehrson a4a6b24cc6 Use correct scopes for getting stream formats 2024-05-21 15:29:57 +02:00
Andreas Pehrson bc1251b594 Serialize more CoreAudio operations
We observed a deadlock on macOS 14 that involved main thread (freezing
the parent process UI) and a CoreAudio getter on a platform callback
thread. This patch mitigates that by moving the getter to the serial
queue.
2024-05-21 15:29:57 +02:00
Andreas Pehrson d6e7528edd In the manual stream tester set input params on the serial queue 2024-05-21 15:29:57 +02:00
Andreas Pehrson d892b0a00c Fix audio-dump feature build
A typo prevented the audio-dump members from being compiled.
A cubeb-backend update is also needed to get the dump types.
2024-05-15 13:47:01 +02:00
Paul Adenot 4ca174cf83 Adjust test, make it extra-clear when we're missing something 2024-04-25 17:51:14 +02:00
Paul Adenot ee8a6a2535 Disable dumping by default, gate it behind a feature flag 2024-04-25 17:51:14 +02:00
Paul Adenot 325648d482 kAudioChannelLabel_Unknown maps to mixer::Channel::Discrete 2024-04-25 17:51:14 +02:00