The audio backend of Firefox on Mac OS X.
Перейти к файлу
Paul Adenot 0cf4308cfa Backport 3 patches on top of 432259ab53
This fixes two crashes, on top of the revision Firefox 76 is using.

commit e8b8a052d8
Author: Paul Adenot <paul@paul.cx>
Date:   Thu Apr 16 18:13:34 2020 +0200

    Don't really push silence to the ring buffer (#86)

commit b49264bfce
Author: Chun-Min Chang <chun.m.chang@gmail.com>
Date:   Thu Apr 9 13:29:24 2020 -0700

    Remove unknown devices when querying devices in scope (#81)

    BMO 1628411 shows we might get some devices whose `AudioObjectID` is
    `kAudioObjectUnknown`. Not sure if it's normal but we can simply remove
    them from the scoped-device list when it happens.

commit 27cf89ef92
Author: Paul Adenot <paul@paul.cx>
Date:   Thu Apr 9 20:22:50 2020 +0200

    Always pass all of the buffered input in the resampler (#79)
2020-04-24 18:16:14 +02:00
.githooks Revise git hooks (#68) 2020-03-26 07:47:24 -07:00
coreaudio-sys-utils Revert `derive(Debug)` removal (#75) 2020-04-01 11:40:16 -07:00
src Backport 3 patches on top of 432259ab53 2020-04-24 18:16:14 +02:00
.editorconfig Add editorconfig 2018-09-10 11:23:29 -07:00
.gitignore create a empty cargo library crate 2018-09-10 11:23:03 -07:00
.travis.yml Bail if `cargo clippy` or `cargo fmt` fails (#65) 2020-03-25 15:38:33 -07:00
Cargo.toml Replace the custom input linear buffer by something based on ringbuf. (#74) 2020-04-01 11:06:21 -07:00
LICENSE Add Readme and License 2018-09-10 11:18:00 -07:00
README.md Revise git hooks (#68) 2020-03-26 07:47:24 -07:00
install_git_hook.sh Add a hook to check that commits are formatted and linted correctly (#66) 2020-03-25 17:45:33 -07:00
install_rustfmt_clippy.sh Run `cargo fmt` and make scripts executable (#62) 2020-03-24 07:58:20 -07:00
run_device_tests.sh Run `cargo fmt` and make scripts executable (#62) 2020-03-24 07:58:20 -07:00
run_sanitizers.sh Bail if `cargo clippy` or `cargo fmt` fails (#65) 2020-03-25 15:38:33 -07:00
run_tests.sh Bail if `cargo clippy` or `cargo fmt` fails (#65) 2020-03-25 15:38:33 -07:00
todo.md Implement a new any-to-any mixer (#23) 2019-12-20 12:45:30 -08:00

README.md

cubeb-coreaudio-rs

Build Status

Rust implementation of Cubeb on the MacOS platform.

Current Goals

  • Keep refactoring the implementation until it looks rusty! (it's translated from C at first.)

Status

The code is currently shipped within the Firefox Nightly under a perf.

  • 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.

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.

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. Only those tests commented with FIXIT are left.

Git Hooks

You can install git hooks by running install_git_hook.sh. Then pre-push script will be run and do the cargo fmt and cargo clippy check before the commits are pushed to remote.

Run Sanitizers

Run AddressSanitizer (ASan), LeakSanitizer (LSan), MemorySanitizer (MSan), ThreadSanitizer (TSan) by sh run_sanitizers.sh.

The above command will run all the test suits in run_tests.sh by all the available sanitizers. However, it takes a long time for finshing the tests.

Device Tests

Run run_device_tests.sh.

If you'd like to run all the device tests with sanitizers, use RUSTFLAGS="-Z sanitizer=<SAN>" sh run_device_tests.sh with valid <SAN> such as address or thread.

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.

Manual Test

  • Output devices switching
    • $ cargo test test_switch_output_device -- --ignored --nocapture
    • Enter s to switch output devices
    • Enter q to finish test
  • Device change events listener
    • $ 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
    • Plug/Unplug devices to see events log.
  • Manual Stream Tester
    • cargo test test_stream_tester -- --ignored --nocapture
      • c to create a stream
      • d to destroy a stream
      • s to start the created stream
      • t to stop the created stream
      • q to quit the test
    • It's useful to simulate the stream bahavior to reproduce the bug we found, with some modified code.

TODO

See todo list

Issues

  • Atomic:
    • We need atomic type around f32 but there is no this type in the stardard Rust
    • Using atomic-rs to do this.
  • kAudioDevicePropertyBufferFrameSize cannot be set when another stream using the same device with smaller buffer size is active. See here for details.

Test issues

  • 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

Branches