• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..31-Mar-2022-

.githooks/H31-Mar-2022-4820

src/H31-Mar-2022-11,98710,082

.cargo-checksum.jsonH A D03-May-202227 11

.editorconfigH A D31-Mar-2022187 1210

.travis.ymlH A D31-Mar-2022331 2322

Cargo.tomlH A D31-Mar-2022444 2219

LICENSEH A D31-Mar-2022731 1311

README.mdH A D31-Mar-20225.4 KiB14098

build-audiounit-rust-in-cubeb.shH A D31-Mar-2022282 119

install_git_hook.shH A D31-Mar-202247 41

install_rustfmt_clippy.shH A D31-Mar-2022846 1814

run_device_tests.shH A D31-Mar-20223 KiB4125

run_sanitizers.shH A D31-Mar-2022677 2113

run_tests.shH A D31-Mar-20221.6 KiB5519

todo.mdH A D31-Mar-20225.8 KiB12592

README.md

1# cubeb-coreaudio-rs
2
3[![Build Status](https://travis-ci.com/ChunMinChang/cubeb-coreaudio-rs.svg?branch=trailblazer)](https://travis-ci.com/ChunMinChang/cubeb-coreaudio-rs)
4
5*Rust* implementation of [Cubeb][cubeb] on [the MacOS platform][cubeb-au].
6
7## Current Goals
8
9- Keep refactoring the implementation until it looks rusty! (it's translated from C at first.)
10  - Check the [todo list][todo]
11
12## Status
13
14This is now the _Firefox_'s default audio backend on *Mac OS*.
15
16## Install
17
18### Install cubeb-coreaudio within cubeb
19
20Run the following command:
21```sh
22curl https://raw.githubusercontent.com/ChunMinChang/cubeb-coreaudio-rs/trailblazer/build-audiounit-rust-in-cubeb.sh | sh
23```
24
25### Other
26
27Just clone this repo
28
29## Test
30
31Please run `sh run_tests.sh`.
32
33Some tests cannot be run in parallel.
34They may operate the same device at the same time,
35or indirectly fire some system events that are listened by some tests.
36
37The tests that may affect others are marked `#[ignore]`.
38They will be run by `cargo test ... -- --ignored ...`
39after finishing normal tests.
40Most of the tests are executed in `run_tests.sh`.
41Only those tests commented with *FIXIT* are left.
42
43### Git Hooks
44
45You can install _git hooks_ by running `install_git_hook.sh`.
46Then _pre-push_ script will be run and do the `cargo fmt` and `cargo clippy` check
47before the commits are pushed to remote.
48
49### Run Sanitizers
50
51Run _AddressSanitizer (ASan), LeakSanitizer (LSan), MemorySanitizer (MSan), ThreadSanitizer (TSan)_
52by `sh run_sanitizers.sh`.
53
54The above command will run all the test suits in *run_tests.sh* by all the available _sanitizers_.
55However, it takes a long time for finshing the tests.
56
57### Device Tests
58
59Run `run_device_tests.sh`.
60
61If you'd like to run all the device tests with sanitizers,
62use `RUSTFLAGS="-Z sanitizer=<SAN>" sh run_device_tests.sh`
63with valid `<SAN>` such as `address` or `thread`.
64
65#### Device Switching
66
67The system default device will be changed during our tests.
68All the available devices will take turns being the system default device.
69However, after finishing the tests, the default device will be set to the original one.
70The sounds in the tests should be able to continue whatever the system default device is.
71
72#### Device Plugging/Unplugging
73
74We implement APIs simulating plugging or unplugging a device
75by adding or removing an aggregate device programmatically.
76It's used to verify our callbacks for minitoring the system devices work.
77
78### Manual Test
79
80- Output devices switching
81  - `$ cargo test test_switch_output_device -- --ignored --nocapture`
82  - Enter `s` to switch output devices
83  - Enter `q` to finish test
84- Device collection change
85  - `cargo test test_device_collection_change -- --ignored --nocapture`
86  - Plug/Unplug devices to see events log.
87- Manual Stream Tester
88  - `cargo test test_stream_tester -- --ignored --nocapture`
89    - `c` to create a stream
90    - `d` to destroy a stream
91    - `s` to start the created stream
92    - `t` to stop the created stream
93    - `r` to register a device changed callback to the created stream
94    - `v` to set volume to the created stream
95    - `q` to quit the test
96  - It's useful to simulate the stream bahavior to reproduce the bug we found,
97    with some modified code.
98
99## TODO
100
101See [todo list][todo]
102
103## Issues
104
105- Atomic:
106  - We need atomic type around `f32` but there is no this type in the stardard Rust
107  - Using [atomic-rs](https://github.com/Amanieu/atomic-rs) to do this.
108- `kAudioDevicePropertyBufferFrameSize` cannot be set when another stream using the same device with smaller buffer size is active. See [here][chg-buf-sz] for details.
109
110### Test issues
111
112- Fail to run tests that depend on `AggregateDevice::create_blank_device` with the tests that work with the device event listeners
113  - The `AggregateDevice::create_blank_device` will add an aggregate device to the system and fire the device-change events indirectly.
114- `TestDeviceSwitcher` cannot work when there is an alive full-duplex stream
115  - An aggregate device will be created for a duplex stream when its input and output devices are different.
116  - `TestDeviceSwitcher` will cached the available devices, upon it's created, as the candidates for default device
117  - Hence the created aggregate device may be cached in `TestDeviceSwitcher`
118  - If the aggregate device is destroyed (when the destroying the duplex stream created it) but the `TestDeviceSwitcher` is still working,
119    it will set a destroyed device as the default device
120  - See details in [device_change.rs](src/backend/tests/device_change.rs)
121
122## Branches
123
124- [trailblazer][trailblazer]: Main branch
125- [plain-translation-from-c][from-c]: The code is rewritten from C code on a line-by-line basis
126- [ocs-disposal][ocs-disposal]: The first version that replace our custom mutex by Rust Mutex
127
128[cubeb]: https://github.com/kinetiknz/cubeb "Cross platform audio library"
129[cubeb-au]: https://github.com/kinetiknz/cubeb/blob/master/src/cubeb_audiounit.cpp "Cubeb AudioUnit"
130
131[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"
132
133[todo]: todo.md
134
135[bmo1572273]: https://bugzilla.mozilla.org/show_bug.cgi?id=1572273
136[bmo1572273-c13]: https://bugzilla.mozilla.org/show_bug.cgi?id=1572273#c13
137
138[from-c]: https://github.com/ChunMinChang/cubeb-coreaudio-rs/tree/plain-translation-from-c
139[ocs-disposal]: https://github.com/ChunMinChang/cubeb-coreaudio-rs/tree/ocs-disposal
140[trailblazer]: https://github.com/ChunMinChang/cubeb-coreaudio-rs/tree/trailblazer