cubeb-coreaudio-rs/README.md

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

2018-09-10 21:18:00 +03:00
# cubeb-coreaudio-rs
2018-09-10 21:20:11 +03:00
Implementation of MacOS Audio backend in CoreAudio framework for [Cubeb][cubeb] written in Rust.
2018-10-08 01:58:11 +03:00
## Current Goals
2018-10-08 02:38:43 +03:00
- Translate [C code][cubeb-au] line by line into Rust
2018-10-08 02:40:35 +03:00
- Create tests for later refactoring
2018-10-08 01:58:11 +03:00
2018-10-08 20:24:56 +03:00
## TODO
2018-10-09 01:52:54 +03:00
- Test aggregate devices
- Test for stream operations
- Clean up the tests. Merge the duplicated pieces in to a function.
2018-10-20 02:21:39 +03:00
- Find a way to catch memory leaks
2018-10-20 02:41:26 +03:00
- Try Instrument on OSX
2018-10-24 02:52:33 +03:00
## Issues
2018-10-31 03:06:43 +03:00
- Mutex: Find a replacement for [`owned_critical_section`](https://github.com/kinetiknz/cubeb/blob/master/src/cubeb_utils_unix.h)
- a dummy mutex like `Mutex<()>` should work (see `test_dummy_mutex_multithread`) as what `owned_critical_section` does in _C_ version, but it doens't has similar API like `assert_current_thread_owns`.
- We implement a `OwnedCriticalSection` around `pthread_mutex_t` like what we do in _C_ version for now.
- Unworkable API: `dispatch_async`
2018-10-24 02:52:33 +03:00
- The second parameter of `dispatch_async` is `dispatch_block_t`, which is defined by `typedef void (^dispatch_block_t)(void)`.
- The caret symbol `^` defines a [block](https://en.wikipedia.org/wiki/Blocks_(C_language_extension)).
- The _block_ is a lambda expression-like syntax to create closures. (See Apple's document: [Working with Blocks](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html))
- Not sure if Rust can work with it. Rust has its own _closure_.
2018-10-31 03:06:43 +03:00
- For now, we implement an API `async_dispatch` to replace `dispatch_async`
- `async_dispatch` is based on `dispatch_async_f`.
- `async_dispatch` takes a _Rust closure_ (instead of Apple's *block*) as one of its parameter.
- prototype on [gist](https://gist.github.com/ChunMinChang/8d13946ebc6c95b2622466c89a0c9bcc)
2018-10-31 03:06:43 +03:00
- The _closure_ (it's a struct) will be `box`ed, which means the _closure_ will be moved into heap, so the _closure_ cannot be optimized as *inline* code.
- Since the _closure_ will be run on an asynchronous thread, we need to move the _closure_ to heap in case it's destroyed when the other thread want to use it.
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"
[cubeb-au]: https://github.com/kinetiknz/cubeb/blob/master/src/cubeb_audiounit.cpp "Cubeb AudioUnit"