cubeb-coreaudio-rs/README.md

97 строки
4.7 KiB
Markdown
Исходник Обычный вид История

2018-09-10 21:18:00 +03:00
# cubeb-coreaudio-rs
2019-03-25 21:21:01 +03:00
[![Build Status](https://travis-ci.org/ChunMinChang/cubeb-coreaudio-rs.svg?branch=trailblazer)](https://travis-ci.org/ChunMinChang/cubeb-coreaudio-rs)
2019-07-22 22:37:14 +03:00
*Rust* implementation of [Cubeb][cubeb] on [the MacOS platform][cubeb-au].
2018-09-10 21:20:11 +03:00
2018-10-08 01:58:11 +03:00
## Current Goals
2019-07-22 22:37:14 +03:00
- Keep refactoring the implementation until it looks rusty!
- Check the [todo list][todo] first
2019-02-19 21:23:12 +03:00
2019-01-11 04:33:06 +03:00
## Status
2019-02-14 02:36:49 +03:00
2019-07-22 22:37:14 +03:00
The code is currently tested in the _Firefox Nightly_ under a _perf_.
2019-02-19 21:23:12 +03:00
2019-07-22 22:37:14 +03:00
- Try it:
- Open `about:config`
- Add a perf `media.cubeb.backend` with string `audiounit-rust`
- Restart Firefox Nightly
- Open `about:support`
- Check if the `Audio Backend` in `Media` section is `audiounit-rust` or not
- Retart Firefox Nightly again if it's not.
2019-05-20 21:13:39 +03:00
2019-04-04 00:49:46 +03:00
## Test
Please run `sh run_tests.sh`.
Some tests cannot be run in parallel.
They may operate the same device at the same time,
or indirectly fire some system events that are listened by some tests.
2019-04-04 01:11:49 +03:00
The tests that may affect others are marked `#[ignore]`.
They will be run by `cargo test ... -- --ignored ...`
after finishing normal tests.
Most of the tests are executed in `run_tests.sh`.
2019-04-04 00:49:46 +03:00
Only those tests commented with *FIXIT* are left.
2019-02-26 22:12:06 +03:00
2019-05-09 19:12:06 +03:00
### Device Switching
The system default device will be changed during our tests.
All the available devices will take turns being the system default device.
However, after finishing the tests, the default device will be set to the original one.
The sounds in the tests should be able to continue whatever the system default device is.
### Device Plugging/Unplugging
We implement APIs simulating plugging or unplugging a device
by adding or removing an aggregate device programmatically.
It's used to verify our callbacks for minitoring the system devices work.
2019-04-04 01:11:49 +03:00
### Manual Test
- Output devices switching
2019-04-05 00:48:19 +03:00
- `$ cargo test test_switch_output_device -- --ignored --nocapture`
- Enter `s` to switch output devices
- Enter `q` to finish test
2019-04-04 01:11:49 +03:00
- Device change events listener
2019-04-05 00:48:19 +03:00
- `$ cargo test test_add_then_remove_listeners -- --ignored --nocapture`
- Plug/Unplug devices or switch input/output devices to see events log.
- Device collection change
- `cargo test test_device_collection_change -- --ignored --nocapture`
2019-04-05 00:48:19 +03:00
- Plug/Unplug devices to see events log.
2019-04-04 01:11:49 +03:00
2018-10-08 20:24:56 +03:00
## TODO
2019-05-28 23:28:07 +03:00
See [TO-DOs][todo]
2018-10-24 02:52:33 +03:00
## Issues
2018-12-06 00:07:39 +03:00
- Atomic:
2019-05-29 02:45:31 +03:00
- We need atomic type around `f32` but there is no this type in the stardard Rust
- Using [atomic-rs](https://github.com/Amanieu/atomic-rs) to do this.
2019-05-28 23:28:07 +03:00
- No guarantee on `audiounit_set_channel_layout`
- This call doesn't work all the times
- Returned `NO_ERR` doesn't guarantee the layout is set to the one we want
- The layouts on some devices won't be changed even no errors are returned,
e.g., we can set _stereo_ layout to a _4-channels aggregate device_ with _QUAD_ layout
(created by Audio MIDI Setup) without any error. However, the layout
of this 4-channels aggregate device is still QUAD after setting it without error
- Another weird thing is that we will get a `kAudioUnitErr_InvalidPropertyValue`
if we set the layout to _QUAD_. It's the same layout as its original one but it cannot be set!
2019-08-15 02:24:18 +03:00
- `kAudioDevicePropertyBufferFrameSize` cannot be set when another stream using the same device with smaller buffer size is active. See [here][chg-buf-sz] for details.
- Potential deadlock issue: see [BMO 1572273][bmo1572273] (especially [comment 13][bmo1572273-c13])
2019-04-04 00:49:46 +03:00
### Test issues
2019-08-15 02:24:18 +03:00
- Fail to run tests that depend on `AggregateDevice::create_blank_device` with the tests that work with the device event listeners
- The `AggregateDevice::create_blank_device` will add an aggregate device to the system and fire the device-change events indirectly.
- `TestDeviceSwitcher` cannot work when there is an alive full-duplex stream
- An aggregate device will be created for a duplex stream when its input and output devices are different.
- `TestDeviceSwitcher` will cached the available devices, upon it's created, as the candidates for default device
- Hence the created aggregate device may be cached in `TestDeviceSwitcher`
- If the aggregate device is destroyed (when the destroying the duplex stream created it) but the `TestDeviceSwitcher` is still working,
it will set a destroyed device as the default device
- See details in [device_change.rs](src/backend/tests/device_change.rs)
2018-10-08 20:24:56 +03:00
2018-10-08 02:38:43 +03:00
[cubeb]: https://github.com/kinetiknz/cubeb "Cross platform audio library"
2018-11-02 21:16:32 +03:00
[cubeb-au]: https://github.com/kinetiknz/cubeb/blob/master/src/cubeb_audiounit.cpp "Cubeb AudioUnit"
2019-02-26 22:12:06 +03:00
[chg-buf-sz]: https://cs.chromium.org/chromium/src/media/audio/mac/audio_manager_mac.cc?l=982-989&rcl=0207eefb445f9855c2ed46280cb835b6f08bdb30 "issue on changing buffer size"
2019-08-15 02:24:18 +03:00
[todo]: todo.md
[bmo1572273]: https://bugzilla.mozilla.org/show_bug.cgi?id=1572273
[bmo1572273-c13]: https://bugzilla.mozilla.org/show_bug.cgi?id=1572273#c13